@waffle-os/runtime 0.0.0-stage → 0.0.146
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.
- package/Cargo.lock +250 -0
- package/Cargo.toml +16 -0
- package/LICENSE +21 -0
- package/LICENSES/Apache-2.0.txt +191 -0
- package/README.md +31 -2
- package/browser/command-input.ts +86 -0
- package/browser/command-owner.ts +5 -0
- package/browser/diagnostic.ts +58 -0
- package/browser/display/generated/graphics-layout.ts +18 -0
- package/browser/display/guest.ts +71 -0
- package/browser/display/launch-retention.ts +59 -0
- package/browser/display/open.ts +45 -0
- package/browser/display/owner.ts +563 -0
- package/browser/display/protocol.ts +24 -0
- package/browser/display/service-protocol.ts +28 -0
- package/browser/display/service-readers.ts +96 -0
- package/browser/display/surface-info.ts +19 -0
- package/browser/filesystem-backend.ts +57 -0
- package/browser/filesystem-worker-backend.ts +27 -0
- package/browser/fs-worker.ts +13 -0
- package/browser/gpu/access.ts +62 -0
- package/browser/gpu/buffers.ts +273 -0
- package/browser/gpu/codec.ts +426 -0
- package/browser/gpu/command-reader.ts +90 -0
- package/browser/gpu/completions.ts +437 -0
- package/browser/gpu/generated/tables.ts +7513 -0
- package/browser/gpu/guest.ts +267 -0
- package/browser/gpu/handles.ts +143 -0
- package/browser/gpu/lowering.ts +238 -0
- package/browser/gpu/metadata.ts +364 -0
- package/browser/gpu/method-coverage.json +1933 -0
- package/browser/gpu/payload.ts +117 -0
- package/browser/gpu/protocol.ts +61 -0
- package/browser/gpu/replay.ts +1067 -0
- package/browser/gpu/ring.ts +336 -0
- package/browser/gpu/scheduler.ts +151 -0
- package/browser/gpu/service-worker.ts +20 -0
- package/browser/gpu/service.ts +490 -0
- package/browser/gpu/stream.json +4175 -0
- package/browser/gpu/surfaces.ts +433 -0
- package/browser/gpu/transport.ts +317 -0
- package/browser/gpu/upstream/LICENSE +29 -0
- package/browser/gpu/upstream/webgpu.h +6774 -0
- package/browser/gpu/upstream/webgpu.yml +5532 -0
- package/browser/guarded-stream.ts +63 -0
- package/browser/net/address.ts +132 -0
- package/browser/net/buffer-module.ts +64 -0
- package/browser/net/helper.ts +1237 -0
- package/browser/net/host.ts +982 -0
- package/browser/net/http1.ts +372 -0
- package/browser/net/module.ts +45 -0
- package/browser/net/namespace.ts +416 -0
- package/browser/net/network.buffer.d.ts +10 -0
- package/browser/net/network.buffer.js +11960 -0
- package/browser/net/network.buffer.sha256 +1 -0
- package/browser/net/network.growth.json +1 -0
- package/browser/net/network.input-hash +1 -0
- package/browser/net/network.sha256 +1 -0
- package/browser/net/network.wasm +0 -0
- package/browser/net/outbound-socket.ts +253 -0
- package/browser/net/outbound.ts +42 -0
- package/browser/net/owner.ts +55 -0
- package/browser/net/protocol.ts +136 -0
- package/browser/net/ring.ts +198 -0
- package/browser/net/runtime.ts +235 -0
- package/browser/net/tcp-status.ts +7 -0
- package/browser/net/transport.ts +26 -0
- package/browser/net/unix-paths.ts +260 -0
- package/browser/net/unix-status.ts +39 -0
- package/browser/notification-blocking-wait.ts +54 -0
- package/browser/notification-relay.ts +76 -0
- package/browser/notification-wait.ts +241 -0
- package/browser/notification-worker.ts +105 -0
- package/browser/operations/cells.ts +90 -0
- package/browser/operations/guest.ts +94 -0
- package/browser/operations/owner.ts +201 -0
- package/browser/operations/protocol.ts +16 -0
- package/browser/operations/types.ts +41 -0
- package/browser/operations/writer.ts +106 -0
- package/browser/persistent-resident-owner.ts +368 -0
- package/browser/preview-host.ts +595 -0
- package/browser/preview-protocol.ts +20 -0
- package/browser/preview.ts +179 -0
- package/browser/preview1-network-types.ts +20 -0
- package/browser/preview1-network.ts +77 -0
- package/browser/preview1-socket.ts +278 -0
- package/browser/preview1-worker.ts +25 -0
- package/browser/process-broker.ts +4209 -0
- package/browser/process-context.ts +56 -0
- package/browser/process-start.ts +133 -0
- package/browser/publication-authority.ts +437 -0
- package/browser/run-command.ts +388 -0
- package/browser/runtime-terminals.ts +183 -0
- package/browser/service-worker.ts +237 -0
- package/browser/shared-fs.ts +742 -0
- package/browser/terminal-input.ts +574 -0
- package/browser/terminal-lifetime.ts +42 -0
- package/browser/terminal-output.ts +491 -0
- package/browser/terminal-session.ts +2225 -0
- package/browser/worker-memory.ts +137 -0
- package/browser/worker-pool.ts +17 -0
- package/browser/worker.ts +1683 -0
- package/build.ts +375 -0
- package/core/descriptors.ts +284 -0
- package/core/devices.ts +20 -0
- package/core/fd-reopen.ts +210 -0
- package/core/filesystem.ts +154 -0
- package/core/index.ts +21 -0
- package/core/memory-views.ts +74 -0
- package/core/open-file.ts +173 -0
- package/core/path.ts +26 -0
- package/core/rights.ts +33 -0
- package/core/unwind.ts +2 -0
- package/core/wasi.ts +1459 -0
- package/dist/browser/command-input.js +82 -0
- package/dist/browser/command-owner.js +2 -0
- package/dist/browser/diagnostic.js +42 -0
- package/dist/browser/display/generated/graphics-layout.js +17 -0
- package/dist/browser/display/guest.js +62 -0
- package/dist/browser/display/launch-retention.js +35 -0
- package/dist/browser/display/open.js +18 -0
- package/dist/browser/display/owner.js +506 -0
- package/dist/browser/display/protocol.js +0 -0
- package/dist/browser/display/service-protocol.js +0 -0
- package/dist/browser/display/service-readers.js +88 -0
- package/dist/browser/display/surface-info.js +18 -0
- package/dist/browser/filesystem-backend.js +29 -0
- package/dist/browser/filesystem-worker-backend.js +20 -0
- package/dist/browser/fs-worker.js +10 -0
- package/dist/browser/gpu/access.js +65 -0
- package/dist/browser/gpu/buffers.js +212 -0
- package/dist/browser/gpu/codec.js +426 -0
- package/dist/browser/gpu/command-reader.js +82 -0
- package/dist/browser/gpu/completions.js +372 -0
- package/dist/browser/gpu/generated/tables.js +7492 -0
- package/dist/browser/gpu/guest.js +239 -0
- package/dist/browser/gpu/handles.js +147 -0
- package/dist/browser/gpu/lowering.js +234 -0
- package/dist/browser/gpu/metadata.js +311 -0
- package/dist/browser/gpu/payload.js +91 -0
- package/dist/browser/gpu/protocol.js +55 -0
- package/dist/browser/gpu/replay.js +871 -0
- package/dist/browser/gpu/ring.js +244 -0
- package/dist/browser/gpu/scheduler.js +124 -0
- package/dist/browser/gpu/service-worker.js +16 -0
- package/dist/browser/gpu/service.js +460 -0
- package/dist/browser/gpu/surfaces.js +394 -0
- package/dist/browser/gpu/transport.js +293 -0
- package/dist/browser/guarded-stream.js +44 -0
- package/dist/browser/net/address.js +98 -0
- package/dist/browser/net/buffer-module.js +60 -0
- package/dist/browser/net/helper.js +1065 -0
- package/dist/browser/net/host.js +896 -0
- package/dist/browser/net/http1.js +305 -0
- package/dist/browser/net/module.js +36 -0
- package/dist/browser/net/namespace.js +396 -0
- package/dist/browser/net/network.buffer.js +11960 -0
- package/dist/browser/net/network.buffer.sha256 +1 -0
- package/dist/browser/net/network.growth.json +1 -0
- package/dist/browser/net/network.input-hash +1 -0
- package/dist/browser/net/network.sha256 +1 -0
- package/dist/browser/net/network.wasm +0 -0
- package/dist/browser/net/outbound-socket.js +226 -0
- package/dist/browser/net/outbound.js +8 -0
- package/dist/browser/net/owner.js +51 -0
- package/dist/browser/net/protocol.js +23 -0
- package/dist/browser/net/ring.js +143 -0
- package/dist/browser/net/runtime.js +177 -0
- package/dist/browser/net/tcp-status.js +5 -0
- package/dist/browser/net/transport.js +12 -0
- package/dist/browser/net/unix-paths.js +178 -0
- package/dist/browser/net/unix-status.js +33 -0
- package/dist/browser/notification-blocking-wait.js +38 -0
- package/dist/browser/notification-relay.js +50 -0
- package/dist/browser/notification-wait.js +179 -0
- package/dist/browser/notification-worker.js +83 -0
- package/dist/browser/operations/cells.js +80 -0
- package/dist/browser/operations/guest.js +67 -0
- package/dist/browser/operations/owner.js +175 -0
- package/dist/browser/operations/protocol.js +0 -0
- package/dist/browser/operations/types.js +0 -0
- package/dist/browser/operations/writer.js +98 -0
- package/dist/browser/persistent-resident-owner.js +264 -0
- package/dist/browser/preview-host.js +435 -0
- package/dist/browser/preview-protocol.js +0 -0
- package/dist/browser/preview.js +161 -0
- package/dist/browser/preview1-network-types.js +0 -0
- package/dist/browser/preview1-network.js +58 -0
- package/dist/browser/preview1-socket.js +273 -0
- package/dist/browser/preview1-worker.js +17 -0
- package/dist/browser/process-broker.js +3361 -0
- package/dist/browser/process-context.js +22 -0
- package/dist/browser/process-start.js +74 -0
- package/dist/browser/publication-authority.js +404 -0
- package/dist/browser/run-command.js +377 -0
- package/dist/browser/runtime-terminals.js +97 -0
- package/dist/browser/service-worker.js +196 -0
- package/dist/browser/shared-fs.js +568 -0
- package/dist/browser/terminal-input.js +562 -0
- package/dist/browser/terminal-lifetime.js +30 -0
- package/dist/browser/terminal-output.js +415 -0
- package/dist/browser/terminal-session.js +1854 -0
- package/dist/browser/worker-memory.js +116 -0
- package/dist/browser/worker-pool.js +14 -0
- package/dist/browser/worker.js +1263 -0
- package/dist/core/descriptors.js +216 -0
- package/dist/core/devices.js +16 -0
- package/dist/core/fd-reopen.js +185 -0
- package/dist/core/filesystem.js +38 -0
- package/dist/core/index.js +8 -0
- package/dist/core/memory-views.js +48 -0
- package/dist/core/open-file.js +141 -0
- package/dist/core/path.js +25 -0
- package/dist/core/rights.js +31 -0
- package/dist/core/unwind.js +2 -0
- package/dist/core/wasi.js +1136 -0
- package/dist/fs/backend.js +885 -0
- package/dist/fs/checkpoint-pressure.js +81 -0
- package/dist/fs/cleanup.js +13 -0
- package/dist/fs/client.js +1808 -0
- package/dist/fs/directory-pages.js +166 -0
- package/dist/fs/dirty-admission.js +196 -0
- package/dist/fs/file-identity.js +149 -0
- package/dist/fs/glob.js +154 -0
- package/dist/fs/guest-watch.js +173 -0
- package/dist/fs/identity-allocation.js +24 -0
- package/dist/fs/idle-database.js +113 -0
- package/dist/fs/idle-owner.js +290 -0
- package/dist/fs/idle-walk.js +112 -0
- package/dist/fs/idle-workspace.js +41 -0
- package/dist/fs/index.js +49 -0
- package/dist/fs/indexeddb-chunks.js +109 -0
- package/dist/fs/indexeddb.js +1421 -0
- package/dist/fs/memory-admission.js +18 -0
- package/dist/fs/memory-budget.js +665 -0
- package/dist/fs/memory.js +1103 -0
- package/dist/fs/namespace-cursor.js +241 -0
- package/dist/fs/namespace-projection-memory-budget.js +59 -0
- package/dist/fs/namespace-projection-owner.js +116 -0
- package/dist/fs/namespace-projection-table.js +660 -0
- package/dist/fs/opfs.js +751 -0
- package/dist/fs/persisted-tree.js +44 -0
- package/dist/fs/persistent.js +819 -0
- package/dist/fs/protocol.js +406 -0
- package/dist/fs/publication-attachment.js +1102 -0
- package/dist/fs/publication-grant.js +463 -0
- package/dist/fs/publication-internal.js +16 -0
- package/dist/fs/publication-memory-budget.js +71 -0
- package/dist/fs/publication-workspace.js +231 -0
- package/dist/fs/publication.js +1294 -0
- package/dist/fs/request-memory.js +728 -0
- package/dist/fs/resolve-observation.js +11 -0
- package/dist/fs/root-construction.js +94 -0
- package/dist/fs/root-memory-budget.js +66 -0
- package/dist/fs/safe-staging.js +547 -0
- package/dist/fs/section.js +37 -0
- package/dist/fs/service.js +1779 -0
- package/dist/fs/shared-capacity.js +5 -0
- package/dist/fs/shared-version-pages.js +46 -0
- package/dist/fs/shared.js +1943 -0
- package/dist/fs/startup.js +26 -0
- package/dist/fs/storage-geometry.js +29 -0
- package/dist/fs/storage-maintenance.js +45 -0
- package/dist/fs/storage.js +306 -0
- package/dist/fs/utf8-size.js +22 -0
- package/dist/fs/vfs-format.js +2 -0
- package/dist/fs/vfs-internal.js +4 -0
- package/dist/fs/vfs.js +121 -0
- package/dist/fs/walk.js +296 -0
- package/dist/fs/watch-account.js +293 -0
- package/dist/fs/watch-arena.js +60 -0
- package/dist/fs/watch-capture.js +77 -0
- package/dist/fs/watch-id-index.js +150 -0
- package/dist/fs/watch-index.js +288 -0
- package/dist/fs/watch-names.js +140 -0
- package/dist/fs/watch-ring.js +172 -0
- package/dist/fs/watch-routing.js +54 -0
- package/dist/fs/watch-service.js +282 -0
- package/dist/fs/watch-subscriptions.js +381 -0
- package/dist/fs/watch.js +78 -0
- package/dist/fs/workspace-archive.js +631 -0
- package/dist/fs/workspace-export.js +309 -0
- package/dist/fs/workspace-import-admission.js +111 -0
- package/dist/fs/workspace-index.js +15 -0
- package/dist/fs/workspace-namespace.js +89 -0
- package/dist/fs/workspace-protocol.js +303 -0
- package/dist/fs/workspace-read.js +576 -0
- package/dist/fs/workspace-search.js +618 -0
- package/dist/fs/workspace-stream.js +210 -0
- package/dist/fs/workspace-types.js +21 -0
- package/dist/fs/workspace.js +557 -0
- package/dist/group/member.js +360 -0
- package/dist/group/protocol.js +35 -0
- package/dist/group/ranges.js +50 -0
- package/dist/group/state.js +846 -0
- package/dist/index.js +27 -0
- package/dist/interrupt/admitted-store.js +180 -0
- package/dist/interrupt/check.js +8 -0
- package/dist/interrupt/index.js +3 -0
- package/dist/interrupt/loader-internal.js +243 -0
- package/dist/interrupt/loader.js +10 -0
- package/dist/interrupt/rewriter-internal.js +942 -0
- package/dist/interrupt/rewriter.js +4 -0
- package/dist/interrupt/wait.js +75 -0
- package/dist/link/code.js +195 -0
- package/dist/link/group.js +258 -0
- package/dist/link/image.js +100 -0
- package/dist/link/index.js +7 -0
- package/dist/link/issuance.js +9 -0
- package/dist/link/metadata.js +455 -0
- package/dist/link/plan.js +264 -0
- package/dist/link/relay.js +46 -0
- package/dist/link/worker.js +44 -0
- package/dist/memory/allocator.js +15 -0
- package/dist/memory/control.js +70 -0
- package/dist/memory/declarations.js +242 -0
- package/dist/memory/graphics-retention.js +10 -0
- package/dist/memory/index.js +8 -0
- package/dist/memory/platform.js +57 -0
- package/dist/memory/reservations.js +970 -0
- package/dist/proc/abi.js +794 -0
- package/dist/proc/access.js +7 -0
- package/dist/proc/admission.js +17 -0
- package/dist/proc/command-runner.js +108 -0
- package/dist/proc/command-stdio.js +176 -0
- package/dist/proc/command-transfer.js +72 -0
- package/dist/proc/command.js +8 -0
- package/dist/proc/control.js +145 -0
- package/dist/proc/directory.js +798 -0
- package/dist/proc/errors.js +20 -0
- package/dist/proc/exec.js +37 -0
- package/dist/proc/filesystem-codec.js +60 -0
- package/dist/proc/identity.js +54 -0
- package/dist/proc/index.js +59 -0
- package/dist/proc/intrinsics/core.js +65 -0
- package/dist/proc/intrinsics/host.js +254 -0
- package/dist/proc/intrinsics.js +99 -0
- package/dist/proc/node-wasi.js +312 -0
- package/dist/proc/observation.js +233 -0
- package/dist/proc/outcome.js +237 -0
- package/dist/proc/pipes.js +1334 -0
- package/dist/proc/registry.js +304 -0
- package/dist/proc/signals.js +179 -0
- package/dist/proc/start-command.js +101 -0
- package/dist/proc/start-diagnostic.js +100 -0
- package/dist/proc/start-errno.js +24 -0
- package/dist/proc/start-failure.js +25 -0
- package/dist/proc/stub.js +17 -0
- package/dist/proc/supervisor.js +1565 -0
- package/dist/proc/table.js +195 -0
- package/dist/proc/terminal-lifetime.js +117 -0
- package/dist/proc/terminal-turn.js +50 -0
- package/dist/proc/types.js +77 -0
- package/dist/proc/wait-status.js +3 -0
- package/dist/proc/worker-access.js +117 -0
- package/dist/proc/worker-broker.js +908 -0
- package/dist/proc/worker-client.js +892 -0
- package/dist/proc/worker-pipes.js +165 -0
- package/dist/programs/catalog.js +27 -0
- package/dist/programs/collection.js +278 -0
- package/dist/programs/download.js +70 -0
- package/dist/programs/index.js +358 -0
- package/dist/runtime.js +774 -0
- package/dist/search/engine.js +299 -0
- package/dist/search/format.js +83 -0
- package/dist/search/index.js +3 -0
- package/dist/search/matcher.js +102 -0
- package/dist/search/paths.js +7 -0
- package/dist/search/search-worker.js +4 -0
- package/dist/search/shard-worker.js +74 -0
- package/dist/search/shards.js +529 -0
- package/dist/search/types.js +7 -0
- package/dist/tests/error-serialization.js +36 -0
- package/dist/tests/page-runner/bootstrap-diagnostics.js +29 -0
- package/dist/tests/page-runner/bootstrap-navigation.js +11 -0
- package/dist/tests/page-runner/browser-observation.js +421 -0
- package/dist/tests/page-runner/collector-fetch.js +70 -0
- package/dist/tests/page-runner/collector.js +635 -0
- package/dist/tests/page-runner/console-observation.js +24 -0
- package/dist/tests/page-runner/continuity-lock-diagnostic.js +301 -0
- package/dist/tests/page-runner/driver.js +41 -0
- package/dist/tests/page-runner/framework-bootstrap.js +9 -0
- package/dist/tests/page-runner/framework-collector.js +219 -0
- package/dist/tests/page-runner/framework-host.js +680 -0
- package/dist/tests/page-runner/framework-http-body.js +47 -0
- package/dist/tests/page-runner/framework-middleware.js +60 -0
- package/dist/tests/page-runner/framework-page.js +12 -0
- package/dist/tests/page-runner/framework-queue.js +344 -0
- package/dist/tests/page-runner/framework-trace.js +458 -0
- package/dist/tests/page-runner/framework-validation.js +44 -0
- package/dist/tests/page-runner/framework.js +7 -0
- package/dist/tests/page-runner/inspector-endpoint-receipt.js +308 -0
- package/dist/tests/page-runner/inspector-endpoint.js +34 -0
- package/dist/tests/page-runner/inspector-plist.js +300 -0
- package/dist/tests/page-runner/inspector-stream.js +99 -0
- package/dist/tests/page-runner/owned-consumers.js +34 -0
- package/dist/tests/page-runner/protocol.js +183 -0
- package/dist/tests/page-runner/report-chunks.js +124 -0
- package/dist/tests/page-runner/report-control.js +7 -0
- package/dist/tests/page-runner/report-stream.js +9 -0
- package/dist/tests/page-runner/result-file.js +15 -0
- package/dist/tests/page-runner/safari-console.js +32 -0
- package/dist/tests/page-runner/safari-driver.js +614 -0
- package/dist/tests/page-runner/safari-observer.js +552 -0
- package/dist/tests/page-runner/service-worker-page.js +93 -0
- package/dist/tests/page-runner/stall-diagnostics.js +506 -0
- package/dist/thread/entry.js +108 -0
- package/dist/thread/guest-bootstrap.js +8 -0
- package/dist/thread/guest-imports.js +272 -0
- package/dist/thread/guest-module.js +4 -0
- package/dist/thread/guest-worker.js +120 -0
- package/dist/thread/lane.js +419 -0
- package/dist/thread/protocol.js +0 -0
- package/dist/thread/runtime-owner.js +561 -0
- package/dist/thread/runtime-protocol.js +0 -0
- package/dist/thread/service-worker.js +81 -0
- package/dist/thread/service.js +396 -0
- package/dist/tooling/program/program-build-tools.js +341 -0
- package/dist/tooling/program/program-build-tools.ts +440 -0
- package/dist/tooling/program/program-derivation.js +102 -0
- package/dist/tooling/program/program-derivation.ts +175 -0
- package/dist/tooling/program/program-optimize.js +246 -0
- package/dist/tooling/program/program-optimize.ts +330 -0
- package/dist/tooling/program/program-transformer.json +1 -0
- package/fs/backend.ts +1111 -0
- package/fs/checkpoint-pressure.ts +102 -0
- package/fs/cleanup.ts +13 -0
- package/fs/client.ts +2283 -0
- package/fs/directory-pages.ts +177 -0
- package/fs/dirty-admission.ts +216 -0
- package/fs/file-identity.ts +175 -0
- package/fs/glob.ts +142 -0
- package/fs/guest-watch.ts +217 -0
- package/fs/identity-allocation.ts +41 -0
- package/fs/idle-database.ts +130 -0
- package/fs/idle-owner.ts +353 -0
- package/fs/idle-walk.ts +126 -0
- package/fs/idle-workspace.ts +88 -0
- package/fs/index.ts +79 -0
- package/fs/indexeddb-chunks.ts +180 -0
- package/fs/indexeddb.ts +1709 -0
- package/fs/memory-admission.ts +19 -0
- package/fs/memory-budget.ts +753 -0
- package/fs/memory.ts +1262 -0
- package/fs/namespace-cursor.ts +260 -0
- package/fs/namespace-projection-memory-budget.ts +58 -0
- package/fs/namespace-projection-owner.ts +149 -0
- package/fs/namespace-projection-table.ts +723 -0
- package/fs/opfs.ts +914 -0
- package/fs/persisted-tree.ts +43 -0
- package/fs/persistent.ts +934 -0
- package/fs/protocol.ts +573 -0
- package/fs/publication-attachment.ts +1269 -0
- package/fs/publication-grant.ts +651 -0
- package/fs/publication-internal.ts +96 -0
- package/fs/publication-memory-budget.ts +77 -0
- package/fs/publication-workspace.ts +242 -0
- package/fs/publication.ts +1820 -0
- package/fs/request-memory.ts +883 -0
- package/fs/resolve-observation.ts +25 -0
- package/fs/root-construction.ts +101 -0
- package/fs/root-memory-budget.ts +64 -0
- package/fs/safe-staging.ts +757 -0
- package/fs/section.ts +42 -0
- package/fs/service.ts +2222 -0
- package/fs/shared-capacity.ts +7 -0
- package/fs/shared-version-pages.ts +59 -0
- package/fs/shared.ts +2454 -0
- package/fs/startup.ts +64 -0
- package/fs/storage-geometry.ts +37 -0
- package/fs/storage-maintenance.ts +95 -0
- package/fs/storage.ts +435 -0
- package/fs/utf8-size.ts +23 -0
- package/fs/vfs-format.ts +3 -0
- package/fs/vfs-internal.ts +10 -0
- package/fs/vfs.ts +203 -0
- package/fs/walk.ts +416 -0
- package/fs/watch-account.ts +312 -0
- package/fs/watch-arena.ts +58 -0
- package/fs/watch-capture.ts +79 -0
- package/fs/watch-id-index.ts +145 -0
- package/fs/watch-index.ts +313 -0
- package/fs/watch-names.ts +139 -0
- package/fs/watch-ring.ts +187 -0
- package/fs/watch-routing.ts +51 -0
- package/fs/watch-service.ts +269 -0
- package/fs/watch-subscriptions.ts +393 -0
- package/fs/watch.ts +81 -0
- package/fs/workspace-archive.ts +721 -0
- package/fs/workspace-export.ts +389 -0
- package/fs/workspace-import-admission.ts +157 -0
- package/fs/workspace-index.ts +16 -0
- package/fs/workspace-namespace.ts +96 -0
- package/fs/workspace-protocol.ts +371 -0
- package/fs/workspace-read.ts +652 -0
- package/fs/workspace-search.ts +788 -0
- package/fs/workspace-stream.ts +274 -0
- package/fs/workspace-types.ts +195 -0
- package/fs/workspace.ts +639 -0
- package/group/member.ts +424 -0
- package/group/protocol.ts +83 -0
- package/group/ranges.ts +51 -0
- package/group/state.ts +1128 -0
- package/index.ts +156 -0
- package/interrupt/admitted-store.ts +245 -0
- package/interrupt/check.ts +15 -0
- package/interrupt/index.ts +3 -0
- package/interrupt/loader-internal.ts +333 -0
- package/interrupt/loader.ts +17 -0
- package/interrupt/rewriter-internal.ts +971 -0
- package/interrupt/rewriter.ts +13 -0
- package/interrupt/wait.ts +111 -0
- package/link/code.ts +145 -0
- package/link/group.ts +396 -0
- package/link/image.ts +124 -0
- package/link/index.ts +12 -0
- package/link/issuance.ts +20 -0
- package/link/metadata.ts +586 -0
- package/link/plan.ts +369 -0
- package/link/relay.ts +80 -0
- package/link/worker.ts +53 -0
- package/memory/allocator.ts +20 -0
- package/memory/control.ts +87 -0
- package/memory/declarations.ts +296 -0
- package/memory/graphics-retention.ts +14 -0
- package/memory/index.ts +21 -0
- package/memory/platform.ts +94 -0
- package/memory/reservations.ts +1421 -0
- package/network/Cargo.toml +26 -0
- package/network/src/abi.rs +100 -0
- package/network/src/lib.rs +440 -0
- package/network/src/module.rs +329 -0
- package/network/src/native.rs +395 -0
- package/network/src/queue.rs +29 -0
- package/network/src/virtual_net.rs +467 -0
- package/network/tests/host_abi.rs +66 -0
- package/network/tests/module.rs +627 -0
- package/network/tests/state.rs +258 -0
- package/network/tests/support/mod.rs +56 -0
- package/network/tests/transport.rs +220 -0
- package/network/tests/virtual.rs +174 -0
- package/package.json +703 -4
- package/patches/wasi-libc/preopen-scan.patch +24 -0
- package/prepare.ts +26 -0
- package/proc/abi.ts +1013 -0
- package/proc/access.ts +21 -0
- package/proc/admission.ts +70 -0
- package/proc/command-runner.ts +131 -0
- package/proc/command-stdio.ts +199 -0
- package/proc/command-transfer.ts +96 -0
- package/proc/command.ts +53 -0
- package/proc/control.ts +198 -0
- package/proc/directory.ts +937 -0
- package/proc/errors.ts +20 -0
- package/proc/exec.ts +46 -0
- package/proc/filesystem-codec.ts +79 -0
- package/proc/identity.ts +55 -0
- package/proc/index.ts +116 -0
- package/proc/intrinsics/core.ts +81 -0
- package/proc/intrinsics/host.ts +346 -0
- package/proc/intrinsics.ts +99 -0
- package/proc/node-wasi.ts +397 -0
- package/proc/observation.ts +293 -0
- package/proc/outcome.ts +276 -0
- package/proc/pipes.ts +1579 -0
- package/proc/registry.ts +556 -0
- package/proc/signals.ts +247 -0
- package/proc/start-command.ts +157 -0
- package/proc/start-diagnostic.ts +109 -0
- package/proc/start-errno.ts +25 -0
- package/proc/start-failure.ts +49 -0
- package/proc/stub.ts +28 -0
- package/proc/supervisor.ts +1877 -0
- package/proc/table.ts +343 -0
- package/proc/terminal-lifetime.ts +125 -0
- package/proc/terminal-turn.ts +62 -0
- package/proc/types.ts +200 -0
- package/proc/wait-status.ts +5 -0
- package/proc/worker-access.ts +143 -0
- package/proc/worker-broker.ts +1086 -0
- package/proc/worker-client.ts +1186 -0
- package/proc/worker-pipes.ts +212 -0
- package/programs/catalog.ts +44 -0
- package/programs/collection.ts +353 -0
- package/programs/download.ts +92 -0
- package/programs/index.ts +584 -0
- package/runtime.ts +1103 -0
- package/rust-toolchain.toml +5 -0
- package/scripts/browser-command.ts +34 -0
- package/scripts/browser-supervisor.ts +158 -0
- package/scripts/build-c-thread-fixture.ts +430 -0
- package/scripts/build-gpu-fixture.ts +279 -0
- package/scripts/build-memory-group-fixture.ts +147 -0
- package/scripts/build-thread-fixture.ts +205 -0
- package/scripts/build-wasi-libc.sh +87 -0
- package/scripts/c-threads-fixture-producer.test.ts +86 -0
- package/scripts/owned-command.ts +89 -0
- package/scripts/test-browser.ts +129 -0
- package/scripts/test-wasi-libc.ts +108 -0
- package/scripts/threads-fixture-producer.test.ts +177 -0
- package/search/engine.ts +363 -0
- package/search/format.ts +102 -0
- package/search/index.ts +11 -0
- package/search/matcher.ts +134 -0
- package/search/paths.ts +11 -0
- package/search/search-worker.ts +6 -0
- package/search/shard-worker.ts +115 -0
- package/search/shards.ts +683 -0
- package/search/types.ts +46 -0
- package/tests/aggregate-memory-contract.test.ts +620 -0
- package/tests/asset-load-recovery-browser-runner.ts +179 -0
- package/tests/asset-load-recovery.test.ts +117 -0
- package/tests/blocking-read-lock-contention.test.ts +305 -0
- package/tests/bootstrap-arrival-browser-runner.ts +19 -0
- package/tests/bootstrap-arrival-runner.test.ts +89 -0
- package/tests/browser-command-real.test.ts +124 -0
- package/tests/browser-command.test.ts +342 -0
- package/tests/browser-controls-discovery.test.ts +56 -0
- package/tests/browser-filesystem-cancel.test.ts +248 -0
- package/tests/browser-filesystem-disposal.test.ts +469 -0
- package/tests/browser-filesystem-failure.test.ts +74 -0
- package/tests/browser-filesystem-options.test.ts +190 -0
- package/tests/browser-filesystem-service-port.test.ts +239 -0
- package/tests/browser-matrix.test.ts +605 -0
- package/tests/browser-navigation-browser-runner.ts +121 -0
- package/tests/browser-navigation.test.ts +106 -0
- package/tests/browser-navigation.ts +49 -0
- package/tests/browser-net-services.test.ts +472 -0
- package/tests/browser-net.test.ts +310 -0
- package/tests/browser-process-broker.test.ts +4172 -0
- package/tests/browser-runner-lifecycle.test.ts +200 -0
- package/tests/browser-runner-lifecycle.ts +328 -0
- package/tests/browser-worker.test.ts +2736 -0
- package/tests/buffer-boundaries.test.ts +52 -0
- package/tests/c-threads-embedding-runner.ts +84 -0
- package/tests/c-threads-fixture-inspect.ts +23 -0
- package/tests/c-threads-fixture.test.ts +142 -0
- package/tests/c-threads-packet-runner.ts +6 -0
- package/tests/c-threads-packet.ts +132 -0
- package/tests/c-threads-paths.test.ts +83 -0
- package/tests/c-threads-positive-worker.ts +5 -0
- package/tests/c-threads-runtime-browser-runner.ts +122 -0
- package/tests/c-threads-runtime-browser.ts +334 -0
- package/tests/c-threads-runtime-guest.ts +14 -0
- package/tests/c-threads-runtime.test.ts +68 -0
- package/tests/c-threads-safari-runner.ts +178 -0
- package/tests/checkpoint-failure-browser.ts +97 -0
- package/tests/checkpoint-pressure.test.ts +602 -0
- package/tests/child-diagnostic-browser.ts +166 -0
- package/tests/child-diagnostic-worker.ts +25 -0
- package/tests/child-diagnostics.test.ts +114 -0
- package/tests/ci-browser-install.test.ts +244 -0
- package/tests/cold-descriptor-lifecycle.test.ts +170 -0
- package/tests/cold-descriptor-read.test.ts +245 -0
- package/tests/command-input.test.ts +40 -0
- package/tests/command-scope.test.ts +422 -0
- package/tests/core-import-boundaries.test.ts +92 -0
- package/tests/core-size-contract.test.ts +327 -0
- package/tests/default-allocation-parity.test.ts +184 -0
- package/tests/descendant-preparation.test.ts +726 -0
- package/tests/descendant-real-worker.test.ts +505 -0
- package/tests/descriptors.test.ts +71 -0
- package/tests/dev-null.test.ts +157 -0
- package/tests/diagnostic-drain.test.ts +62 -0
- package/tests/dirty-admission.test.ts +572 -0
- package/tests/durable-file-identity.test.ts +586 -0
- package/tests/durable-identity-storage.test.ts +112 -0
- package/tests/error-serialization.test.ts +94 -0
- package/tests/error-serialization.ts +34 -0
- package/tests/exec-integration.test.ts +94 -0
- package/tests/fd-reopen.test.ts +4 -0
- package/tests/file-offset-contention.test.ts +186 -0
- package/tests/file-times.test.ts +353 -0
- package/tests/filesystem-allocation-context.test.ts +198 -0
- package/tests/filesystem-atomic.test.ts +564 -0
- package/tests/filesystem-capacity.test.ts +34 -0
- package/tests/filesystem-client-intrinsics.test.ts +288 -0
- package/tests/filesystem-codec.test.ts +227 -0
- package/tests/filesystem-conditional-remove.test.ts +200 -0
- package/tests/filesystem-endpoint-observer.test.ts +371 -0
- package/tests/filesystem-glob.test.ts +38 -0
- package/tests/filesystem-io-fastpath.test.ts +339 -0
- package/tests/filesystem-large-file.test.ts +61 -0
- package/tests/filesystem-lazy-backing.test.ts +440 -0
- package/tests/filesystem-nonblocking.test.ts +339 -0
- package/tests/filesystem-permissions.test.ts +348 -0
- package/tests/filesystem-persistence-shared.test.ts +375 -0
- package/tests/filesystem-port-transport.test.ts +275 -0
- package/tests/filesystem-private-input.test.ts +1155 -0
- package/tests/filesystem-publication-grant.test.ts +674 -0
- package/tests/filesystem-publication-workspace.test.ts +2105 -0
- package/tests/filesystem-publication.test.ts +1774 -0
- package/tests/filesystem-quiescence-rearm.test.ts +76 -0
- package/tests/filesystem-quiescence.test.ts +522 -0
- package/tests/filesystem-readlink-shared.test.ts +311 -0
- package/tests/filesystem-ready-disposal-browser-runner.ts +243 -0
- package/tests/filesystem-refcount.test.ts +552 -0
- package/tests/filesystem-request-memory.test.ts +202 -0
- package/tests/filesystem-request-pool.test.ts +408 -0
- package/tests/filesystem-resolve-observation.test.ts +185 -0
- package/tests/filesystem-retired-release.test.ts +37 -0
- package/tests/filesystem-review.test.ts +284 -0
- package/tests/filesystem-segment.test.ts +339 -0
- package/tests/filesystem-shared.test.ts +304 -0
- package/tests/filesystem-shutdown-browser-debt.ts +267 -0
- package/tests/filesystem-shutdown-browser-runner.ts +524 -0
- package/tests/filesystem-shutdown-browser.ts +290 -0
- package/tests/filesystem-shutdown-close-observation.test.ts +437 -0
- package/tests/filesystem-shutdown-close-observation.ts +206 -0
- package/tests/filesystem-shutdown-observer.test.ts +93 -0
- package/tests/filesystem-shutdown.test.ts +893 -0
- package/tests/filesystem-staged-write.test.ts +909 -0
- package/tests/filesystem-stop-observer.ts +50 -0
- package/tests/filesystem-storage-geometry.test.ts +404 -0
- package/tests/filesystem-transfer.test.ts +135 -0
- package/tests/filesystem-transport-browser-driver.ts +28 -0
- package/tests/filesystem-transport-browser-runner.ts +134 -0
- package/tests/filesystem-transport-browser.ts +179 -0
- package/tests/filesystem-transport-codec.test.ts +96 -0
- package/tests/filesystem-walk.test.ts +524 -0
- package/tests/filesystem-worker.test.ts +676 -0
- package/tests/first-worker-import.ts +118 -0
- package/tests/fixtures/asset-load-recovery-page.ts +95 -0
- package/tests/fixtures/bigint-hooks.ts +28 -0
- package/tests/fixtures/browser-cell-clone.ts +100 -0
- package/tests/fixtures/browser-process-child.ts +25 -0
- package/tests/fixtures/buffer-boundaries.ts +65 -0
- package/tests/fixtures/cold-descriptor-guest.ts +58 -0
- package/tests/fixtures/cold-descriptor.ts +162 -0
- package/tests/fixtures/cold-range-proof-lifecycle.ts +136 -0
- package/tests/fixtures/command-bounded-admission.ts +31 -0
- package/tests/fixtures/command-disposal.ts +47 -0
- package/tests/fixtures/command-guests.ts +123 -0
- package/tests/fixtures/default-allocation-capture.ts +239 -0
- package/tests/fixtures/descendant-real-worker.ts +121 -0
- package/tests/fixtures/diagnostic-public.ts +14 -0
- package/tests/fixtures/documented-startup-control.ts +33 -0
- package/tests/fixtures/durable-identity-opfs.ts +123 -0
- package/tests/fixtures/exec-browser-worker.ts +5 -0
- package/tests/fixtures/exec-guest.ts +279 -0
- package/tests/fixtures/exec-integration.ts +305 -0
- package/tests/fixtures/exec-node-control.ts +22 -0
- package/tests/fixtures/exec-node-host.ts +31 -0
- package/tests/fixtures/exec-node-worker.ts +11 -0
- package/tests/fixtures/exec-worker.ts +33 -0
- package/tests/fixtures/fd-kind-cases.ts +81 -0
- package/tests/fixtures/fd-reopen-cases.ts +489 -0
- package/tests/fixtures/file-offset-contention.ts +110 -0
- package/tests/fixtures/file-only-abi.ts +48 -0
- package/tests/fixtures/file-times-guest.ts +151 -0
- package/tests/fixtures/file-times-storage.ts +76 -0
- package/tests/fixtures/file-times-worker.ts +16 -0
- package/tests/fixtures/file-times.ts +16 -0
- package/tests/fixtures/filesystem-atomic-guest.ts +94 -0
- package/tests/fixtures/filesystem-default-service.ts +3 -0
- package/tests/fixtures/filesystem-diagnostic-transfer-failure.ts +15 -0
- package/tests/fixtures/filesystem-endpoint-observer.ts +159 -0
- package/tests/fixtures/filesystem-endpoint-service.ts +53 -0
- package/tests/fixtures/filesystem-file.ts +23 -0
- package/tests/fixtures/filesystem-guest.ts +119 -0
- package/tests/fixtures/filesystem-host.ts +47 -0
- package/tests/fixtures/filesystem-offset-guest.ts +48 -0
- package/tests/fixtures/filesystem-permissions-worker.ts +44 -0
- package/tests/fixtures/filesystem-port-service.ts +32 -0
- package/tests/fixtures/filesystem-port-worker.ts +71 -0
- package/tests/fixtures/filesystem-proc-guest.ts +59 -0
- package/tests/fixtures/filesystem-quiescence-guest.ts +23 -0
- package/tests/fixtures/filesystem-refcount-guest.ts +75 -0
- package/tests/fixtures/filesystem-request-release-worker.ts +32 -0
- package/tests/fixtures/filesystem-segment-guest.ts +46 -0
- package/tests/fixtures/filesystem-service.ts +17 -0
- package/tests/fixtures/filesystem-shutdown-debt-page.ts +178 -0
- package/tests/fixtures/filesystem-shutdown-debt-worker.ts +116 -0
- package/tests/fixtures/filesystem-shutdown-page.ts +288 -0
- package/tests/fixtures/filesystem-shutdown-worker.ts +168 -0
- package/tests/fixtures/filesystem-startup-failure.ts +24 -0
- package/tests/fixtures/filesystem-transport-observation-worker.ts +5 -0
- package/tests/fixtures/filesystem-walk-worker.ts +45 -0
- package/tests/fixtures/generic-memory-node-worker.ts +16 -0
- package/tests/fixtures/global-lock-holder.ts +55 -0
- package/tests/fixtures/gpu/async-expected.json +506 -0
- package/tests/fixtures/gpu/async-host.ts +263 -0
- package/tests/fixtures/gpu/async-native.ts +507 -0
- package/tests/fixtures/gpu/async-page.ts +193 -0
- package/tests/fixtures/gpu/async.c +463 -0
- package/tests/fixtures/gpu/async_encode.h +170 -0
- package/tests/fixtures/gpu/bootstrap-cleanup-worker.ts +135 -0
- package/tests/fixtures/gpu/bundle-query-expected.json +400 -0
- package/tests/fixtures/gpu/bundle-query-fixture.ts +121 -0
- package/tests/fixtures/gpu/bundle-query-native.ts +674 -0
- package/tests/fixtures/gpu/compute-expected.json +187 -0
- package/tests/fixtures/gpu/compute-native.ts +418 -0
- package/tests/fixtures/gpu/copy-draw-expected.json +372 -0
- package/tests/fixtures/gpu/copy-draw-fixture.ts +82 -0
- package/tests/fixtures/gpu/copy-draw-native.ts +690 -0
- package/tests/fixtures/gpu/core-fixture.ts +202 -0
- package/tests/fixtures/gpu/core-transport-worker.ts +76 -0
- package/tests/fixtures/gpu/desktop-arm-contract.ts +180 -0
- package/tests/fixtures/gpu/desktop-fairness-contract.ts +99 -0
- package/tests/fixtures/gpu/desktop-fairness-observation.ts +79 -0
- package/tests/fixtures/gpu/disposal-retirement.ts +21 -0
- package/tests/fixtures/gpu/enums.json +46 -0
- package/tests/fixtures/gpu/expected.json +251 -0
- package/tests/fixtures/gpu/fairness-observer.ts +504 -0
- package/tests/fixtures/gpu/fairness-test-data.ts +164 -0
- package/tests/fixtures/gpu/fairness-validation.ts +325 -0
- package/tests/fixtures/gpu/fixture-runtime.ts +48 -0
- package/tests/fixtures/gpu/gpu_encode.h +236 -0
- package/tests/fixtures/gpu/gpu_fixture.h +237 -0
- package/tests/fixtures/gpu/import-unwind.ts +12 -0
- package/tests/fixtures/gpu/integration-guest.ts +244 -0
- package/tests/fixtures/gpu/integration-page.ts +805 -0
- package/tests/fixtures/gpu/integration-service-worker.ts +113 -0
- package/tests/fixtures/gpu/label-expected.json +219 -0
- package/tests/fixtures/gpu/label-native.ts +280 -0
- package/tests/fixtures/gpu/lazy-page.ts +39 -0
- package/tests/fixtures/gpu/measurement-contract.ts +148 -0
- package/tests/fixtures/gpu/measurement-desktop.ts +121 -0
- package/tests/fixtures/gpu/measurement-page.ts +347 -0
- package/tests/fixtures/gpu/measurement-runtime.ts +82 -0
- package/tests/fixtures/gpu/measurement-worker.ts +310 -0
- package/tests/fixtures/gpu/ownership-reader-terminal-worker.ts +42 -0
- package/tests/fixtures/gpu/ownership-service-worker.ts +920 -0
- package/tests/fixtures/gpu/peer-input.ts +6 -0
- package/tests/fixtures/gpu/qualification-contract.ts +42 -0
- package/tests/fixtures/gpu/qualification-page.ts +67 -0
- package/tests/fixtures/gpu/qualification-webgpu.ts +199 -0
- package/tests/fixtures/gpu/qualification-worker.ts +97 -0
- package/tests/fixtures/gpu/ring-snapshot.ts +25 -0
- package/tests/fixtures/gpu/ring-worker.ts +227 -0
- package/tests/fixtures/gpu/runtime-display-fence-launcher.ts +16 -0
- package/tests/fixtures/gpu/runtime-display-fence.ts +193 -0
- package/tests/fixtures/gpu/runtime-disposal-signal-order.ts +195 -0
- package/tests/fixtures/gpu/runtime-disposal-signal-worker.ts +79 -0
- package/tests/fixtures/gpu/scene-expected.json +360 -0
- package/tests/fixtures/gpu/scene-fixture.ts +73 -0
- package/tests/fixtures/gpu/scene-native.ts +473 -0
- package/tests/fixtures/gpu/scene.c +73 -0
- package/tests/fixtures/gpu/scene_encode.h +302 -0
- package/tests/fixtures/gpu/service-access.ts +39 -0
- package/tests/fixtures/gpu/service-bootstrap-worker.ts +10 -0
- package/tests/fixtures/gpu/service-reader-worker.ts +29 -0
- package/tests/fixtures/gpu/thrown-observation.ts +120 -0
- package/tests/fixtures/gpu/triangle.c +480 -0
- package/tests/fixtures/gpu/waffle_gpu_stream.h +2046 -0
- package/tests/fixtures/group-futex-worker.ts +102 -0
- package/tests/fixtures/group-link-program.ts +18 -0
- package/tests/fixtures/guarded-nonblock-worker.ts +37 -0
- package/tests/fixtures/guest-watch-runtime-worker.ts +115 -0
- package/tests/fixtures/guest-watch-worker.ts +41 -0
- package/tests/fixtures/guest-watch-writer-worker.ts +46 -0
- package/tests/fixtures/host-failure-worker.ts +17 -0
- package/tests/fixtures/indexeddb-background-confirmation.ts +33 -0
- package/tests/fixtures/indexeddb-caller-delivery.ts +100 -0
- package/tests/fixtures/installer-symlinks-support.ts +25 -0
- package/tests/fixtures/interrupt-browser-loops.ts +78 -0
- package/tests/fixtures/interrupt-browser-worker.ts +104 -0
- package/tests/fixtures/interrupt-browser-workload.ts +17 -0
- package/tests/fixtures/interrupt-dom-consumer.ts +9 -0
- package/tests/fixtures/interrupt-wait-wasm.ts +108 -0
- package/tests/fixtures/interrupt-wait-worker.ts +61 -0
- package/tests/fixtures/intrinsics.ts +114 -0
- package/tests/fixtures/isolated-process.ts +98 -0
- package/tests/fixtures/lazy-backing-constructions.ts +117 -0
- package/tests/fixtures/lazy-backing-guest.ts +219 -0
- package/tests/fixtures/lazy-backing.ts +226 -0
- package/tests/fixtures/link-initialization-worker.ts +112 -0
- package/tests/fixtures/link-initialization.ts +169 -0
- package/tests/fixtures/link-member-workers.ts +73 -0
- package/tests/fixtures/link-relay-program.ts +76 -0
- package/tests/fixtures/link-relay-worker.ts +77 -0
- package/tests/fixtures/linked-nested-node-worker.ts +50 -0
- package/tests/fixtures/logical-process-context-guest.ts +37 -0
- package/tests/fixtures/memory-group-abi-worker.ts +108 -0
- package/tests/fixtures/memory-group-member.c +215 -0
- package/tests/fixtures/memory-group-pie.ts +46 -0
- package/tests/fixtures/memory-group-wake-worker.ts +14 -0
- package/tests/fixtures/memory-group-worker.ts +18 -0
- package/tests/fixtures/memory-observation-guest.ts +90 -0
- package/tests/fixtures/metadata-completion-observer-worker.ts +13 -0
- package/tests/fixtures/metadata-enumeration-r173-service.ts +71 -0
- package/tests/fixtures/metadata-enumeration-r173-store.ts +51 -0
- package/tests/fixtures/metadata-enumeration-r173-wasi.ts +168 -0
- package/tests/fixtures/metadata-enumeration-r173-worker.ts +68 -0
- package/tests/fixtures/navigation-wire-child.ts +134 -0
- package/tests/fixtures/nested-wasi.ts +260 -0
- package/tests/fixtures/network-fence-script.ts +46 -0
- package/tests/fixtures/network-hook-positions.json +16 -0
- package/tests/fixtures/network-original-nodes.json +149 -0
- package/tests/fixtures/node-wasi-descriptors.ts +203 -0
- package/tests/fixtures/node-worker-transfers.ts +11 -0
- package/tests/fixtures/notification-collecting-worker.ts +7 -0
- package/tests/fixtures/notification-controlled-relay.ts +57 -0
- package/tests/fixtures/notification-deadline-worker.ts +128 -0
- package/tests/fixtures/notification-mixed-worker.ts +215 -0
- package/tests/fixtures/notification-probed-worker.ts +53 -0
- package/tests/fixtures/notification-reject-worker.ts +7 -0
- package/tests/fixtures/notification-runtime-worker.ts +55 -0
- package/tests/fixtures/notification-send-failure-worker.ts +60 -0
- package/tests/fixtures/notification-stalled-worker.ts +5 -0
- package/tests/fixtures/notification-traffic-worker.ts +71 -0
- package/tests/fixtures/operation-fs-worker.ts +114 -0
- package/tests/fixtures/operation-observer-worker.ts +41 -0
- package/tests/fixtures/operation-page.ts +522 -0
- package/tests/fixtures/opfs-close-page.ts +94 -0
- package/tests/fixtures/opfs-close-worker.ts +565 -0
- package/tests/fixtures/opfs-range-storage.ts +285 -0
- package/tests/fixtures/owned-job-root-worker.ts +84 -0
- package/tests/fixtures/owned-job-wait-worker.ts +56 -0
- package/tests/fixtures/owner-freeze-guest.ts +81 -0
- package/tests/fixtures/owner-freeze-owner.ts +77 -0
- package/tests/fixtures/page-root-client.ts +33 -0
- package/tests/fixtures/permissions-guest.ts +55 -0
- package/tests/fixtures/permissions-storage.ts +97 -0
- package/tests/fixtures/persistent-authority-observer.ts +27 -0
- package/tests/fixtures/persistent-lifecycle-r2-owner.ts +149 -0
- package/tests/fixtures/persistent-ready.ts +34 -0
- package/tests/fixtures/pipe-filestat-guest.ts +101 -0
- package/tests/fixtures/pipe-filestat-worker.ts +36 -0
- package/tests/fixtures/pipe-reuse-worker.ts +41 -0
- package/tests/fixtures/pipes-intrinsics.ts +63 -0
- package/tests/fixtures/preopen-guest.c +44 -0
- package/tests/fixtures/preopen-node-host.ts +13 -0
- package/tests/fixtures/prepared-program-loading-control.ts +42 -0
- package/tests/fixtures/prepared-runtime-control.ts +80 -0
- package/tests/fixtures/preview-wire-headers-page.ts +84 -0
- package/tests/fixtures/preview1-entry.ts +1 -0
- package/tests/fixtures/preview1-listener.wat +44 -0
- package/tests/fixtures/preview1-relay.wat +24 -0
- package/tests/fixtures/preview1-socket-imports.wat +36 -0
- package/tests/fixtures/preview1-socket-unknown.wat +4 -0
- package/tests/fixtures/preview1-socket-worker.ts +72 -0
- package/tests/fixtures/preview1-socket.c +58 -0
- package/tests/fixtures/preview1-socket.wat +19 -0
- package/tests/fixtures/private-authority-cases.ts +260 -0
- package/tests/fixtures/process-abi-guest.ts +67 -0
- package/tests/fixtures/process-abi-poll-guest.ts +84 -0
- package/tests/fixtures/process-cell-clone.ts +520 -0
- package/tests/fixtures/process-context-guest.ts +22 -0
- package/tests/fixtures/process-filesystem.ts +34 -0
- package/tests/fixtures/process-intrinsics.ts +360 -0
- package/tests/fixtures/process-lookup.ts +6 -0
- package/tests/fixtures/process-observation-acquisition-worker.ts +68 -0
- package/tests/fixtures/process-observation-controls.ts +15 -0
- package/tests/fixtures/process-observation-worker.ts +72 -0
- package/tests/fixtures/process-poll-start-failure.ts +68 -0
- package/tests/fixtures/process-root-navigation-original-bun-lock.txt +333 -0
- package/tests/fixtures/process-root-navigation-original-runner.txt +378 -0
- package/tests/fixtures/process-start-worker.ts +32 -0
- package/tests/fixtures/program-shell.ts +86 -0
- package/tests/fixtures/publication-channel-observer.ts +144 -0
- package/tests/fixtures/publication-cleanup-failure.ts +16 -0
- package/tests/fixtures/publication-guest.ts +296 -0
- package/tests/fixtures/publication-launch-close.ts +61 -0
- package/tests/fixtures/publication-resident-authority.ts +464 -0
- package/tests/fixtures/publication-resident-guest.ts +331 -0
- package/tests/fixtures/publication-storage.ts +30 -0
- package/tests/fixtures/publication-wasm.ts +103 -0
- package/tests/fixtures/readlink-service.ts +19 -0
- package/tests/fixtures/recovery-r42-owner.ts +49 -0
- package/tests/fixtures/recovery-r42-page.ts +67 -0
- package/tests/fixtures/reservation-waste-worker.ts +16 -0
- package/tests/fixtures/resident-memory.ts +11 -0
- package/tests/fixtures/retained-client.ts +26 -0
- package/tests/fixtures/root-return-gc.ts +121 -0
- package/tests/fixtures/running-member-wasm.ts +55 -0
- package/tests/fixtures/running-member-worker.ts +50 -0
- package/tests/fixtures/runtime-filesystem-close-debt.ts +142 -0
- package/tests/fixtures/runtime-stop-control.ts +229 -0
- package/tests/fixtures/search-count-worker.ts +265 -0
- package/tests/fixtures/search-fault-shard.ts +21 -0
- package/tests/fixtures/search-program-fs-worker.ts +34 -0
- package/tests/fixtures/shared-caller-debt-control.ts +13 -0
- package/tests/fixtures/shared-caller-exec-worker.ts +119 -0
- package/tests/fixtures/shared-caller-exec.ts +597 -0
- package/tests/fixtures/shared-caller-host-failure-control.ts +92 -0
- package/tests/fixtures/shared-memory-platform.ts +6 -0
- package/tests/fixtures/socket-admission-relay.ts +114 -0
- package/tests/fixtures/spawn-diagnostic-guest.ts +44 -0
- package/tests/fixtures/spawn-request.ts +14 -0
- package/tests/fixtures/stable-memory-grow-worker.ts +10 -0
- package/tests/fixtures/stable-memory-reader.ts +253 -0
- package/tests/fixtures/standalone-runtime-process.ts +19 -0
- package/tests/fixtures/start-failure-public.ts +8 -0
- package/tests/fixtures/start-failure-quiet-worker.ts +54 -0
- package/tests/fixtures/startup-diagnostic-request.ts +8 -0
- package/tests/fixtures/startup-diagnostic-worker.ts +62 -0
- package/tests/fixtures/startup-pool-worker.ts +19 -0
- package/tests/fixtures/stop-order-wasm.ts +60 -0
- package/tests/fixtures/stop-order-worker.ts +11 -0
- package/tests/fixtures/storage-lifecycle-fs-prelude.ts +15 -0
- package/tests/fixtures/storage-lifecycle-fs-worker.ts +2 -0
- package/tests/fixtures/storage-lock-startup.ts +70 -0
- package/tests/fixtures/storage-maintenance.ts +16 -0
- package/tests/fixtures/symlink-sizing-probe.ts +59 -0
- package/tests/fixtures/terminal-control-worker.ts +150 -0
- package/tests/fixtures/terminal-input-pause.ts +30 -0
- package/tests/fixtures/terminal-input-producer.ts +18 -0
- package/tests/fixtures/terminal-mode-worker.ts +58 -0
- package/tests/fixtures/terminal-resolver-worker.ts +92 -0
- package/tests/fixtures/thread-admission-control.ts +294 -0
- package/tests/fixtures/threads-c.c +117 -0
- package/tests/fixtures/threads.rs +140 -0
- package/tests/fixtures/truncate-page-work.ts +32 -0
- package/tests/fixtures/wasi-atomic-host.ts +92 -0
- package/tests/fixtures/wasi-cat.ts +177 -0
- package/tests/fixtures/wasi-nonblock-inherited-worker.ts +34 -0
- package/tests/fixtures/wasi-nonblock-worker.ts +33 -0
- package/tests/fixtures/wasi-nonblock.ts +48 -0
- package/tests/fixtures/wasi-poll-guest.ts +45 -0
- package/tests/fixtures/wasi-write.ts +72 -0
- package/tests/fixtures/wasm-start-section.ts +88 -0
- package/tests/fixtures/watch-delivery-error-worker.ts +4 -0
- package/tests/fixtures/watch-guest.ts +141 -0
- package/tests/fixtures/watch-lifecycle-worker.ts +2 -0
- package/tests/fixtures/watch-startup-error-worker.ts +1 -0
- package/tests/fixtures/worker-pipe-transfer-guest.ts +58 -0
- package/tests/fixtures/workspace-endurance.ts +113 -0
- package/tests/fixtures/workspace-read-claim.ts +41 -0
- package/tests/fixtures/workspace-read.ts +104 -0
- package/tests/fixtures/workspace-recovery.ts +133 -0
- package/tests/fs-socket-attachment-browser.ts +184 -0
- package/tests/fs-socket-browser-runner.ts +35 -0
- package/tests/fs-socket-node.test.ts +123 -0
- package/tests/fs-socket-owner.test.ts +106 -0
- package/tests/fs-socket-scope.test.ts +285 -0
- package/tests/gated-indexeddb.test.ts +16 -0
- package/tests/gated-indexeddb.ts +72 -0
- package/tests/git-install.test.ts +25 -0
- package/tests/gpu-admission-browser.ts +763 -0
- package/tests/gpu-admission-controls.test.ts +592 -0
- package/tests/gpu-asset-paths.test.ts +107 -0
- package/tests/gpu-async-assets.ts +29 -0
- package/tests/gpu-async-browser-runner.ts +20 -0
- package/tests/gpu-async-command.test.ts +249 -0
- package/tests/gpu-async-command.ts +272 -0
- package/tests/gpu-async-desktop.ts +78 -0
- package/tests/gpu-async-fixture.test.ts +252 -0
- package/tests/gpu-async-native.test.ts +38 -0
- package/tests/gpu-async-native.ts +70 -0
- package/tests/gpu-async-output.test.ts +49 -0
- package/tests/gpu-async-payload.test.ts +537 -0
- package/tests/gpu-async-replay.test.ts +656 -0
- package/tests/gpu-async-stream.test.ts +166 -0
- package/tests/gpu-bootstrap-cleanup.test.ts +185 -0
- package/tests/gpu-browser-controls.test.ts +64 -0
- package/tests/gpu-browser-qualification.test.ts +102 -0
- package/tests/gpu-browser-qualification.ts +432 -0
- package/tests/gpu-browser-runner.ts +554 -0
- package/tests/gpu-browser-shared.ts +59 -0
- package/tests/gpu-bundle-query-native.test.ts +8 -0
- package/tests/gpu-bundle-query-native.ts +55 -0
- package/tests/gpu-bundle-query-replay.test.ts +406 -0
- package/tests/gpu-bundle-query-stream.test.ts +97 -0
- package/tests/gpu-ci.test.ts +244 -0
- package/tests/gpu-completions.test.ts +404 -0
- package/tests/gpu-compute-native.test.ts +9 -0
- package/tests/gpu-compute-native.ts +47 -0
- package/tests/gpu-compute-replay.test.ts +363 -0
- package/tests/gpu-compute-stream.test.ts +53 -0
- package/tests/gpu-control-retention.test.ts +202 -0
- package/tests/gpu-copy-draw-native.test.ts +9 -0
- package/tests/gpu-copy-draw-native.ts +71 -0
- package/tests/gpu-copy-draw-replay.test.ts +350 -0
- package/tests/gpu-copy-draw-stream.test.ts +78 -0
- package/tests/gpu-coverage.test.ts +250 -0
- package/tests/gpu-desktop-measure.test.ts +344 -0
- package/tests/gpu-display-retirement.test.ts +213 -0
- package/tests/gpu-display-shutdown.test.ts +180 -0
- package/tests/gpu-disposal-browser.ts +685 -0
- package/tests/gpu-disposal-controls.test.ts +738 -0
- package/tests/gpu-disposal-retirement.test.ts +108 -0
- package/tests/gpu-fairness-browser.ts +273 -0
- package/tests/gpu-fairness-fixture.test.ts +202 -0
- package/tests/gpu-fairness.test.ts +203 -0
- package/tests/gpu-fixture-closed.test.ts +232 -0
- package/tests/gpu-fixture-host.ts +253 -0
- package/tests/gpu-fixture.test.ts +569 -0
- package/tests/gpu-grant-quota-browser.ts +767 -0
- package/tests/gpu-grant-quota-controls.test.ts +525 -0
- package/tests/gpu-grant-retirement.test.ts +413 -0
- package/tests/gpu-import-observation.test.ts +472 -0
- package/tests/gpu-integration.test.ts +479 -0
- package/tests/gpu-label-native.test.ts +8 -0
- package/tests/gpu-label-native.ts +37 -0
- package/tests/gpu-label-replay.test.ts +313 -0
- package/tests/gpu-label-stream.test.ts +135 -0
- package/tests/gpu-launch-retention.test.ts +134 -0
- package/tests/gpu-loading-browser.ts +54 -0
- package/tests/gpu-loading.test.ts +97 -0
- package/tests/gpu-malformed-browser.ts +522 -0
- package/tests/gpu-malformed-controls.test.ts +720 -0
- package/tests/gpu-measure.test.ts +281 -0
- package/tests/gpu-native-browser-runner.ts +48 -0
- package/tests/gpu-native-controls.test.ts +181 -0
- package/tests/gpu-native-controls.ts +117 -0
- package/tests/gpu-ownership-browser.ts +642 -0
- package/tests/gpu-ownership-controls.test.ts +373 -0
- package/tests/gpu-payload-pressure-browser.ts +1142 -0
- package/tests/gpu-payload-pressure-controls.test.ts +974 -0
- package/tests/gpu-payload-settlement.test.ts +323 -0
- package/tests/gpu-peer-input.test.ts +98 -0
- package/tests/gpu-reader-terminal.test.ts +194 -0
- package/tests/gpu-regrant-browser.ts +861 -0
- package/tests/gpu-regrant-controls.test.ts +680 -0
- package/tests/gpu-replay.test.ts +511 -0
- package/tests/gpu-ring-snapshot.test.ts +53 -0
- package/tests/gpu-ring.test.ts +497 -0
- package/tests/gpu-scene-fixture.test.ts +272 -0
- package/tests/gpu-scene-native.test.ts +14 -0
- package/tests/gpu-scene-native.ts +36 -0
- package/tests/gpu-scene-replay.test.ts +678 -0
- package/tests/gpu-scene-stream.test.ts +112 -0
- package/tests/gpu-service-bootstrap.test.ts +61 -0
- package/tests/gpu-service-failure-browser.ts +792 -0
- package/tests/gpu-service-failure-controls.test.ts +1035 -0
- package/tests/gpu-service-failure-ordering.test.ts +105 -0
- package/tests/gpu-service-readers.test.ts +247 -0
- package/tests/gpu-stream.test.ts +338 -0
- package/tests/gpu-surface-transfer.test.ts +855 -0
- package/tests/gpu-transport.test.ts +311 -0
- package/tests/gpu-worker-bundle.test.ts +31 -0
- package/tests/group-futex-browser-runner.ts +150 -0
- package/tests/group-futex-browser.ts +141 -0
- package/tests/group-futex.test.ts +798 -0
- package/tests/guarded-stream-nonblock.test.ts +130 -0
- package/tests/guest-watch-browser-cases.test.ts +24 -0
- package/tests/guest-watch-browser-cases.ts +271 -0
- package/tests/guest-watch-browser-runner.ts +66 -0
- package/tests/host-interface.test.ts +115 -0
- package/tests/host.test.ts +349 -0
- package/tests/http1-buffer-boundaries.test.ts +102 -0
- package/tests/http1-framing-limits.test.ts +419 -0
- package/tests/idle-workspace-browser.ts +350 -0
- package/tests/idle-workspace-cancellation-browser.ts +129 -0
- package/tests/idle-workspace-fixtures.ts +25 -0
- package/tests/idle-workspace-maintenance-browser.ts +271 -0
- package/tests/idle-workspace-metadata-browser.ts +287 -0
- package/tests/imports.test.ts +92 -0
- package/tests/indexeddb-checkpoint-decode-browser.ts +232 -0
- package/tests/indexeddb-checkpoint-decode.test.ts +32 -0
- package/tests/indexeddb-chunks-browser-runner.ts +39 -0
- package/tests/indexeddb-chunks-browser.ts +841 -0
- package/tests/indexeddb-chunks.test.ts +57 -0
- package/tests/indexeddb-publication-browser.ts +458 -0
- package/tests/indexeddb-publication.test.ts +89 -0
- package/tests/indexeddb-storage-browser.ts +1357 -0
- package/tests/inherited-fd-review.test.ts +362 -0
- package/tests/inherited-fd.test.ts +82 -0
- package/tests/installer-symlinks-alias.test.ts +266 -0
- package/tests/installer-symlinks-borrow.test.ts +451 -0
- package/tests/installer-symlinks-codec.test.ts +117 -0
- package/tests/installer-symlinks-creation.test.ts +369 -0
- package/tests/installer-symlinks-final-components.test.ts +392 -0
- package/tests/installer-symlinks-history.test.ts +155 -0
- package/tests/installer-symlinks-metadata-types.ts +32 -0
- package/tests/installer-symlinks-metadata.test.ts +140 -0
- package/tests/installer-symlinks-persistence.test.ts +120 -0
- package/tests/installer-symlinks-readlink.test.ts +444 -0
- package/tests/installer-symlinks-service.test.ts +125 -0
- package/tests/installer-symlinks-tree.test.ts +88 -0
- package/tests/installer-symlinks.test.ts +251 -0
- package/tests/interrupt-admitted-browser-runner.ts +290 -0
- package/tests/interrupt-admitted-browser.ts +167 -0
- package/tests/interrupt-admitted-fixture.ts +44 -0
- package/tests/interrupt-admitted-loader.test.ts +324 -0
- package/tests/interrupt-admitted-store.test.ts +195 -0
- package/tests/interrupt-browser-benchmark.ts +208 -0
- package/tests/interrupt-browser-control.ts +55 -0
- package/tests/interrupt-browser-fixtures.test.ts +40 -0
- package/tests/interrupt-browser-runner-control.ts +52 -0
- package/tests/interrupt-browser-runner.test.ts +125 -0
- package/tests/interrupt-browser.ts +251 -0
- package/tests/interrupt-cache-storage-fixture.ts +58 -0
- package/tests/interrupt-check.test.ts +47 -0
- package/tests/interrupt-loader-cache.test.ts +383 -0
- package/tests/interrupt-loader.test.ts +111 -0
- package/tests/interrupt-rewriter-exports.test.ts +11 -0
- package/tests/interrupt-rewriter.test.ts +740 -0
- package/tests/interrupt-standard-eh.test.ts +293 -0
- package/tests/interrupt-transform-pin.test.ts +16 -0
- package/tests/interrupt-wait-profile.test.ts +126 -0
- package/tests/interrupt-wait.test.ts +328 -0
- package/tests/intrinsics-boundary.test.ts +377 -0
- package/tests/isolated-page-runner.ts +186 -0
- package/tests/libc-tooling.test.ts +313 -0
- package/tests/link-browser-runner.ts +167 -0
- package/tests/link-browser.ts +61 -0
- package/tests/link-initialization.test.ts +344 -0
- package/tests/link-member-workers.test.ts +83 -0
- package/tests/link-program.test.ts +1642 -0
- package/tests/link-quickjs-worker.ts +140 -0
- package/tests/link-quickjs.test.ts +83 -0
- package/tests/link-relay-browser.ts +94 -0
- package/tests/link-shared-basic512-fixture.ts +48 -0
- package/tests/link-shared-basic512.test.ts +129 -0
- package/tests/loopback-fetch-bun-consumer.test.ts +121 -0
- package/tests/loopback-fetch-compression.test.ts +204 -0
- package/tests/loopback-fetch-fixture.ts +128 -0
- package/tests/loopback-fetch-redirect.test.ts +321 -0
- package/tests/loopback-fetch-worker.ts +115 -0
- package/tests/memory-budget.test.ts +952 -0
- package/tests/memory-group-browser-runner.ts +123 -0
- package/tests/memory-group-browser.ts +649 -0
- package/tests/memory-group-cap.test.ts +200 -0
- package/tests/memory-group-exit-lock.test.ts +325 -0
- package/tests/memory-group-grow.test.ts +151 -0
- package/tests/memory-group-link.test.ts +485 -0
- package/tests/memory-group-pin-port.test.ts +170 -0
- package/tests/memory-group-pin.test.ts +275 -0
- package/tests/memory-group-review.test.ts +286 -0
- package/tests/memory-group-stack-worker.ts +94 -0
- package/tests/memory-group-state.test.ts +537 -0
- package/tests/memory-reservations.test.ts +804 -0
- package/tests/memory-views.test.ts +168 -0
- package/tests/metadata-directory-contract-r173.test.ts +307 -0
- package/tests/metadata-nlink-r173.test.ts +201 -0
- package/tests/metadata-readdir-r173.test.ts +126 -0
- package/tests/metadata-worker-completion.test.ts +29 -0
- package/tests/namespace-cursor.test.ts +470 -0
- package/tests/namespace-projection-memory-budget.test.ts +250 -0
- package/tests/namespace-projection-owner.test.ts +880 -0
- package/tests/namespace-projection-table.test.ts +1598 -0
- package/tests/nested-wasi.test.ts +7 -0
- package/tests/net-host-watch.test.ts +236 -0
- package/tests/net-transport-metadata.test.ts +81 -0
- package/tests/network-activation-browser.ts +71 -0
- package/tests/network-address.test.ts +412 -0
- package/tests/network-browser-runner.ts +21 -0
- package/tests/network-browser-service-worker.ts +19 -0
- package/tests/network-browser-worker.ts +147 -0
- package/tests/network-browser.test.ts +22 -0
- package/tests/network-browser.ts +679 -0
- package/tests/network-budget.test.ts +103 -0
- package/tests/network-command-controls.ts +87 -0
- package/tests/network-command.test.ts +253 -0
- package/tests/network-command.ts +274 -0
- package/tests/network-control-page.ts +32 -0
- package/tests/network-desktop-driver.ts +66 -0
- package/tests/network-failure-control.ts +332 -0
- package/tests/network-failure.test.ts +14 -0
- package/tests/network-finalizer.test.ts +61 -0
- package/tests/network-finalizer.ts +17 -0
- package/tests/network-flow-cases.ts +146 -0
- package/tests/network-flow-control.test.ts +43 -0
- package/tests/network-growth-control.ts +18 -0
- package/tests/network-growth.test.ts +27 -0
- package/tests/network-lazy.test.ts +260 -0
- package/tests/network-lookup-consumer.test.ts +193 -0
- package/tests/network-lookup-handles.test.ts +527 -0
- package/tests/network-lookup-node.test.ts +32 -0
- package/tests/network-lookup-worker.ts +83 -0
- package/tests/network-lookup.test.ts +134 -0
- package/tests/network-module-host.test.ts +263 -0
- package/tests/network-module.test.ts +76 -0
- package/tests/network-namespace.test.ts +562 -0
- package/tests/network-outbound.test.ts +786 -0
- package/tests/network-page-contract.ts +24 -0
- package/tests/network-page-inputs.ts +79 -0
- package/tests/network-page-suite.ts +183 -0
- package/tests/network-page.ts +14 -0
- package/tests/network-path-scope.test.ts +93 -0
- package/tests/network-relay-browser-runner.ts +10 -0
- package/tests/network-relay-browser.ts +384 -0
- package/tests/network-relay-contract.ts +35 -0
- package/tests/network-relay-fixture.ts +249 -0
- package/tests/network-relay-modules.ts +21 -0
- package/tests/network-relay-page.ts +10 -0
- package/tests/network-relay-runner.test.ts +171 -0
- package/tests/network-relay-worker.ts +137 -0
- package/tests/network-resource-control.ts +73 -0
- package/tests/network-ring-wake.test.ts +186 -0
- package/tests/network-safari-websocket.test.ts +272 -0
- package/tests/network-sentinel-assets.ts +6 -0
- package/tests/network-signal-control.test.ts +8 -0
- package/tests/network-signal-control.ts +101 -0
- package/tests/network-signal-controls.ts +52 -0
- package/tests/network-size.test.ts +22 -0
- package/tests/network-source-parity.test.ts +95 -0
- package/tests/network-source-parity.ts +240 -0
- package/tests/network-unix-fs.test.ts +297 -0
- package/tests/network-unix-guest.ts +41 -0
- package/tests/network-unix-races.test.ts +370 -0
- package/tests/network-unix-support.ts +93 -0
- package/tests/network-unix.test.ts +600 -0
- package/tests/network-wire.test.ts +198 -0
- package/tests/network-worker-peer.ts +88 -0
- package/tests/node-exports.test.ts +258 -0
- package/tests/node-wasi-descriptors.test.ts +32 -0
- package/tests/notification-admission.test.ts +51 -0
- package/tests/notification-browser-runner.ts +92 -0
- package/tests/notification-command.test.ts +130 -0
- package/tests/notification-command.ts +230 -0
- package/tests/notification-fairness-browser-runner.ts +66 -0
- package/tests/notification-fairness-cases.ts +327 -0
- package/tests/notification-lifetime-cases.ts +457 -0
- package/tests/notification-mixed-cases.ts +220 -0
- package/tests/notification-race-browser-runner.ts +26 -0
- package/tests/notification-race-cases.ts +54 -0
- package/tests/notification-relay-retention.test.ts +133 -0
- package/tests/notification-wait.test.ts +100 -0
- package/tests/operation-diagnostics-browser.ts +192 -0
- package/tests/operation-diagnostics.test.ts +291 -0
- package/tests/opfs-close-browser-observer.test.ts +319 -0
- package/tests/opfs-close-browser-runner.ts +434 -0
- package/tests/opfs-close-browser.ts +113 -0
- package/tests/opfs-close.test.ts +504 -0
- package/tests/opfs-qualification-browser.ts +297 -0
- package/tests/opfs-range-browser-runner.ts +86 -0
- package/tests/opfs-range-browser.ts +202 -0
- package/tests/opfs-range.test.ts +331 -0
- package/tests/opfs-snapshot.test.ts +224 -0
- package/tests/opfs-storage-browser.ts +1109 -0
- package/tests/owned-job-cleanup.test.ts +1167 -0
- package/tests/owner-freeze-browser-runner.ts +571 -0
- package/tests/owner-freeze-browser.ts +226 -0
- package/tests/packaging.test.ts +278 -0
- package/tests/page-runner/aggregate-error-fixture.ts +18 -0
- package/tests/page-runner/asset-hold-control-page.ts +7 -0
- package/tests/page-runner/asset-hold-controls.ts +132 -0
- package/tests/page-runner/asset-owner.test.ts +635 -0
- package/tests/page-runner/asset-owner.ts +251 -0
- package/tests/page-runner/bootstrap-arrival-browser.test.ts +139 -0
- package/tests/page-runner/bootstrap-arrival.test.ts +344 -0
- package/tests/page-runner/bootstrap-control.ts +19 -0
- package/tests/page-runner/bootstrap-diagnostics.test.ts +133 -0
- package/tests/page-runner/bootstrap-diagnostics.ts +35 -0
- package/tests/page-runner/bootstrap-navigation.ts +19 -0
- package/tests/page-runner/browser-controls-process-fixture.ts +112 -0
- package/tests/page-runner/browser-controls-runner.test.ts +380 -0
- package/tests/page-runner/browser-controls-runner.ts +130 -0
- package/tests/page-runner/browser-controls-suite.ts +443 -0
- package/tests/page-runner/browser-observation.test.ts +448 -0
- package/tests/page-runner/browser-observation.ts +469 -0
- package/tests/page-runner/collector-fetch.ts +93 -0
- package/tests/page-runner/collector-policy.test.ts +216 -0
- package/tests/page-runner/collector.test.ts +429 -0
- package/tests/page-runner/collector.ts +993 -0
- package/tests/page-runner/command-controls.ts +334 -0
- package/tests/page-runner/command-fixtures.ts +46 -0
- package/tests/page-runner/command-host.test.ts +167 -0
- package/tests/page-runner/command-observation.test.ts +358 -0
- package/tests/page-runner/command-page.ts +21 -0
- package/tests/page-runner/command-suites.ts +142 -0
- package/tests/page-runner/console-control-page.ts +33 -0
- package/tests/page-runner/console-control-worker.ts +14 -0
- package/tests/page-runner/console-controls.ts +174 -0
- package/tests/page-runner/console-first-line-worker.ts +2 -0
- package/tests/page-runner/console-late-control-page.ts +25 -0
- package/tests/page-runner/console-late-control.test.ts +214 -0
- package/tests/page-runner/console-late-control.ts +398 -0
- package/tests/page-runner/console-lifecycle.test.ts +139 -0
- package/tests/page-runner/console-observation.test.ts +73 -0
- package/tests/page-runner/console-observation.ts +49 -0
- package/tests/page-runner/consumer-control-chunk.ts +1 -0
- package/tests/page-runner/consumer-control-page.ts +147 -0
- package/tests/page-runner/consumer-control-worker.ts +4 -0
- package/tests/page-runner/consumer-controls.ts +345 -0
- package/tests/page-runner/consumer-entry.test.ts +856 -0
- package/tests/page-runner/consumer-page.ts +8 -0
- package/tests/page-runner/consumer.ts +39 -0
- package/tests/page-runner/continuity-lock-browser.test.ts +29 -0
- package/tests/page-runner/continuity-lock-control-page.ts +430 -0
- package/tests/page-runner/continuity-lock-diagnostic.test.ts +122 -0
- package/tests/page-runner/continuity-lock-diagnostic.ts +380 -0
- package/tests/page-runner/control-run.test.ts +112 -0
- package/tests/page-runner/control-run.ts +44 -0
- package/tests/page-runner/cross-tab-evaluator.ts +162 -0
- package/tests/page-runner/cross-tab-value.ts +59 -0
- package/tests/page-runner/document-retirement.test.ts +288 -0
- package/tests/page-runner/driver-observation-cleanup.test.ts +63 -0
- package/tests/page-runner/driver-observation-diagnostics.test.ts +93 -0
- package/tests/page-runner/driver.ts +118 -0
- package/tests/page-runner/error-context.test.ts +95 -0
- package/tests/page-runner/fake-driver.ts +192 -0
- package/tests/page-runner/filesystem-transport-browser.test.ts +75 -0
- package/tests/page-runner/filesystem-transport-native.ts +13 -0
- package/tests/page-runner/filesystem-transport-observation.ts +65 -0
- package/tests/page-runner/filesystem-transport-page.ts +48 -0
- package/tests/page-runner/filesystem-transport-suite.test.ts +310 -0
- package/tests/page-runner/filesystem-transport-suite.ts +127 -0
- package/tests/page-runner/fixture-admission.test.ts +167 -0
- package/tests/page-runner/fixture-capability-control-page.ts +24 -0
- package/tests/page-runner/fixture-capability-controls.ts +189 -0
- package/tests/page-runner/fixture-host.test.ts +524 -0
- package/tests/page-runner/fixture-owner.test.ts +176 -0
- package/tests/page-runner/fixture-owner.ts +189 -0
- package/tests/page-runner/fixtures/large-assertion.ts +21 -0
- package/tests/page-runner/framework-bootstrap-main.ts +22 -0
- package/tests/page-runner/framework-bootstrap.ts +311 -0
- package/tests/page-runner/framework-collector.test.ts +277 -0
- package/tests/page-runner/framework-collector.ts +287 -0
- package/tests/page-runner/framework-controls/installed.ts +433 -0
- package/tests/page-runner/framework-dom-controls.ts +685 -0
- package/tests/page-runner/framework-dom-page.ts +136 -0
- package/tests/page-runner/framework-final-ack.test.ts +79 -0
- package/tests/page-runner/framework-host.test.ts +443 -0
- package/tests/page-runner/framework-host.ts +899 -0
- package/tests/page-runner/framework-http-body.ts +44 -0
- package/tests/page-runner/framework-middleware.test.ts +85 -0
- package/tests/page-runner/framework-middleware.ts +73 -0
- package/tests/page-runner/framework-page.ts +37 -0
- package/tests/page-runner/framework-queue.test.ts +405 -0
- package/tests/page-runner/framework-queue.ts +417 -0
- package/tests/page-runner/framework-reporting.test.ts +451 -0
- package/tests/page-runner/framework-trace-host.test.ts +106 -0
- package/tests/page-runner/framework-trace-page.ts +483 -0
- package/tests/page-runner/framework-trace-regression.test.ts +300 -0
- package/tests/page-runner/framework-trace.test.ts +793 -0
- package/tests/page-runner/framework-trace.ts +509 -0
- package/tests/page-runner/framework-types.ts +255 -0
- package/tests/page-runner/framework-validation.test.ts +52 -0
- package/tests/page-runner/framework-validation.ts +65 -0
- package/tests/page-runner/framework-verdict.test.ts +259 -0
- package/tests/page-runner/framework.ts +37 -0
- package/tests/page-runner/gpu-async-controls-runner.ts +108 -0
- package/tests/page-runner/gpu-async-failure-controls.ts +93 -0
- package/tests/page-runner/gpu-async-native.ts +6 -0
- package/tests/page-runner/gpu-async-operations.ts +49 -0
- package/tests/page-runner/gpu-async-page.ts +14 -0
- package/tests/page-runner/gpu-async-request.ts +3 -0
- package/tests/page-runner/gpu-async-suite.test.ts +189 -0
- package/tests/page-runner/gpu-async-suite.ts +120 -0
- package/tests/page-runner/guest-watch-command.ts +11 -0
- package/tests/page-runner/guest-watch-control-phases.ts +20 -0
- package/tests/page-runner/guest-watch-controls-runner.ts +134 -0
- package/tests/page-runner/guest-watch-stalled-helper.ts +5 -0
- package/tests/page-runner/host-drive-control-page.ts +90 -0
- package/tests/page-runner/host-drive-controls.test.ts +91 -0
- package/tests/page-runner/host-drive-controls.ts +318 -0
- package/tests/page-runner/host-drive.test.ts +2222 -0
- package/tests/page-runner/host-drive.ts +1311 -0
- package/tests/page-runner/host-page.test.ts +58 -0
- package/tests/page-runner/host-page.ts +207 -0
- package/tests/page-runner/host-storage-control-page.ts +182 -0
- package/tests/page-runner/host-storage-control-worker.ts +11 -0
- package/tests/page-runner/host-storage-controls.ts +313 -0
- package/tests/page-runner/host.test.ts +133 -0
- package/tests/page-runner/inspector-endpoint-receipt.ts +425 -0
- package/tests/page-runner/inspector-endpoint.test.ts +236 -0
- package/tests/page-runner/inspector-endpoint.ts +69 -0
- package/tests/page-runner/inspector-plist.ts +395 -0
- package/tests/page-runner/inspector-stream.test.ts +149 -0
- package/tests/page-runner/inspector-stream.ts +105 -0
- package/tests/page-runner/json-snapshot.ts +8 -0
- package/tests/page-runner/key-press-control-page.ts +17 -0
- package/tests/page-runner/key-press-controls-native.ts +7 -0
- package/tests/page-runner/key-press-controls.ts +78 -0
- package/tests/page-runner/key-press-fixture.ts +109 -0
- package/tests/page-runner/key-press-observation.ts +129 -0
- package/tests/page-runner/key-press-suite.ts +138 -0
- package/tests/page-runner/large-reporting.test.ts +351 -0
- package/tests/page-runner/lifecycle-queue.test.ts +186 -0
- package/tests/page-runner/memory-group-command.test.ts +227 -0
- package/tests/page-runner/memory-group-command.ts +80 -0
- package/tests/page-runner/memory-group-control-page.ts +7 -0
- package/tests/page-runner/memory-group-controls-runner.ts +126 -0
- package/tests/page-runner/native-cli.test.ts +86 -0
- package/tests/page-runner/native-failure.test.ts +396 -0
- package/tests/page-runner/native.ts +62 -0
- package/tests/page-runner/notification-host.test.ts +264 -0
- package/tests/page-runner/notification-native.ts +6 -0
- package/tests/page-runner/ordered-reporter.ts +305 -0
- package/tests/page-runner/owned-consumers.ts +36 -0
- package/tests/page-runner/page-main.ts +137 -0
- package/tests/page-runner/peer-collector.test.ts +356 -0
- package/tests/page-runner/peer-control-page.ts +33 -0
- package/tests/page-runner/peer-controls.ts +249 -0
- package/tests/page-runner/peer-driver-fixture.test.ts +219 -0
- package/tests/page-runner/peer-driver-fixture.ts +257 -0
- package/tests/page-runner/peer-host.test.ts +248 -0
- package/tests/page-runner/peer-probe.test.ts +131 -0
- package/tests/page-runner/peer-storage-control-page.ts +51 -0
- package/tests/page-runner/peer-storage-controls.ts +116 -0
- package/tests/page-runner/playwright-driver.test.ts +270 -0
- package/tests/page-runner/playwright-driver.ts +229 -0
- package/tests/page-runner/playwright-observer.ts +137 -0
- package/tests/page-runner/prepared-assets.test.ts +91 -0
- package/tests/page-runner/process-recycling-assets.ts +34 -0
- package/tests/page-runner/process-recycling-controls-page.ts +27 -0
- package/tests/page-runner/process-recycling-controls.test.ts +70 -0
- package/tests/page-runner/process-recycling-controls.ts +134 -0
- package/tests/page-runner/process-recycling-error-control-worker.ts +2 -0
- package/tests/page-runner/process-recycling-fs-control-worker.ts +3 -0
- package/tests/page-runner/process-recycling-native.ts +46 -0
- package/tests/page-runner/process-recycling-page.ts +24 -0
- package/tests/page-runner/process-recycling-storage-control.ts +11 -0
- package/tests/page-runner/process-recycling-suite.test.ts +202 -0
- package/tests/page-runner/process-recycling-suite.ts +38 -0
- package/tests/page-runner/protocol.ts +286 -0
- package/tests/page-runner/publication-bootstrap.ts +65 -0
- package/tests/page-runner/publication-cross-tab-browser.test.ts +68 -0
- package/tests/page-runner/publication-cross-tab-host.ts +211 -0
- package/tests/page-runner/publication-cross-tab-native.ts +6 -0
- package/tests/page-runner/publication-cross-tab-page.ts +24 -0
- package/tests/page-runner/publication-cross-tab-suite.test.ts +181 -0
- package/tests/page-runner/publication-cross-tab-suite.ts +87 -0
- package/tests/page-runner/publication-native.ts +11 -0
- package/tests/page-runner/publication-page.ts +46 -0
- package/tests/page-runner/publication-suite.test.ts +100 -0
- package/tests/page-runner/publication-suite.ts +99 -0
- package/tests/page-runner/report-chunks.test.ts +295 -0
- package/tests/page-runner/report-chunks.ts +195 -0
- package/tests/page-runner/report-control.ts +12 -0
- package/tests/page-runner/report-stream.ts +12 -0
- package/tests/page-runner/reporter-control-failure.test.ts +119 -0
- package/tests/page-runner/reporter-control-page.ts +101 -0
- package/tests/page-runner/reporter.test.ts +237 -0
- package/tests/page-runner/reporter.ts +28 -0
- package/tests/page-runner/reporting-cleanup.test.ts +118 -0
- package/tests/page-runner/reporting-contract.test.ts +242 -0
- package/tests/page-runner/reporting-fixture.ts +130 -0
- package/tests/page-runner/reporting-host.test.ts +149 -0
- package/tests/page-runner/reporting-realm.ts +4 -0
- package/tests/page-runner/reporting-types.ts +22 -0
- package/tests/page-runner/result-file.ts +18 -0
- package/tests/page-runner/retained-worker-control-page.ts +23 -0
- package/tests/page-runner/retained-worker-controls.ts +107 -0
- package/tests/page-runner/root-continuity-allocation.ts +21 -0
- package/tests/page-runner/root-continuity-control-fixture.ts +11 -0
- package/tests/page-runner/root-continuity-controls.ts +237 -0
- package/tests/page-runner/root-continuity-gate-page.ts +94 -0
- package/tests/page-runner/root-continuity-page.ts +48 -0
- package/tests/page-runner/root-continuity-suite.test.ts +290 -0
- package/tests/page-runner/root-continuity-suite.ts +102 -0
- package/tests/page-runner/safari-console.ts +40 -0
- package/tests/page-runner/safari-driver-log.test.ts +202 -0
- package/tests/page-runner/safari-driver.test.ts +474 -0
- package/tests/page-runner/safari-driver.ts +763 -0
- package/tests/page-runner/safari-error.test.ts +61 -0
- package/tests/page-runner/safari-navigation.test.ts +220 -0
- package/tests/page-runner/safari-observer.test.ts +868 -0
- package/tests/page-runner/safari-observer.ts +665 -0
- package/tests/page-runner/safari-session-startup.test.ts +139 -0
- package/tests/page-runner/safe-staging-allocation.ts +19 -0
- package/tests/page-runner/safe-staging-control-page.ts +58 -0
- package/tests/page-runner/safe-staging-controls-runner.ts +53 -0
- package/tests/page-runner/safe-staging-page.ts +27 -0
- package/tests/page-runner/safe-staging-suite.ts +70 -0
- package/tests/page-runner/safe-staging.test.ts +145 -0
- package/tests/page-runner/service-worker-page.ts +132 -0
- package/tests/page-runner/stall-diagnostics.test.ts +380 -0
- package/tests/page-runner/stall-diagnostics.ts +627 -0
- package/tests/page-runner/storage-cleanup.ts +83 -0
- package/tests/page-runner/storage-control-page.ts +124 -0
- package/tests/page-runner/storage-control-worker.ts +36 -0
- package/tests/page-runner/storage-host.ts +51 -0
- package/tests/page-runner/storage-page-control-worker.ts +15 -0
- package/tests/page-runner/storage-page.ts +14 -0
- package/tests/page-runner/storage-policy.ts +74 -0
- package/tests/page-runner/storage-worker.test.ts +30 -0
- package/tests/page-runner/storage-worker.ts +154 -0
- package/tests/page-runner/suite-host.ts +1259 -0
- package/tests/page-runner/suite-query.test.ts +164 -0
- package/tests/page-runner/suite-startup.test.ts +102 -0
- package/tests/page-runner/threads-runtime-browser.test.ts +68 -0
- package/tests/page-runner/threads-runtime-native.ts +31 -0
- package/tests/page-runner/threads-runtime-page.ts +19 -0
- package/tests/page-runner/threads-runtime-suite.test.ts +245 -0
- package/tests/page-runner/threads-runtime-suite.ts +162 -0
- package/tests/page-runner/worker-allocation.test.ts +161 -0
- package/tests/page-runner/worker-capability-control-page.ts +91 -0
- package/tests/page-runner/worker-capability-controls.ts +394 -0
- package/tests/page-runner/worker-close-query.test.ts +229 -0
- package/tests/page-runner/worker-lifecycle-browser.test.ts +104 -0
- package/tests/page-runner/worker-lifecycle-control-page.ts +18 -0
- package/tests/persistence-close.test.ts +359 -0
- package/tests/persistence-durability.test.ts +588 -0
- package/tests/persistence-queue.test.ts +324 -0
- package/tests/persistence.test.ts +788 -0
- package/tests/persistent-authority-browser-runner.ts +518 -0
- package/tests/persistent-authority-browser.ts +25 -0
- package/tests/persistent-authority-report.test.ts +216 -0
- package/tests/persistent-authority-report.ts +81 -0
- package/tests/persistent-lifecycle-r2-browser-runner.ts +503 -0
- package/tests/persistent-lifecycle-r2-page.ts +248 -0
- package/tests/persistent-lifecycle-r2.test.ts +114 -0
- package/tests/persistent-native-inspection.test.ts +254 -0
- package/tests/persistent-native-inspection.ts +179 -0
- package/tests/persistent-ready.test.ts +54 -0
- package/tests/persistent-resident-owner.test.ts +612 -0
- package/tests/pinned-truncate.test.ts +137 -0
- package/tests/pipe-description-flags.test.ts +29 -0
- package/tests/pipe-filestat-browser.ts +182 -0
- package/tests/pipe-filestat.test.ts +157 -0
- package/tests/pipe-persistent-lifetime.test.ts +134 -0
- package/tests/pipe-reader-lifetime.test.ts +46 -0
- package/tests/pipe-reader-reuse-races.test.ts +228 -0
- package/tests/pipe-registry-allocator.test.ts +35 -0
- package/tests/pipe-reuse-worker.test.ts +112 -0
- package/tests/pipe-shared-allocator.test.ts +170 -0
- package/tests/pipe-slot-reuse.test.ts +500 -0
- package/tests/pipes.test.ts +1669 -0
- package/tests/preopen-placement.test.ts +236 -0
- package/tests/prepared-platform-boundary.test.ts +26 -0
- package/tests/preview-host-reference.test.ts +51 -0
- package/tests/preview-host-reference.ts +155 -0
- package/tests/preview-host.test.ts +875 -0
- package/tests/preview-network-fixture.ts +150 -0
- package/tests/preview-upgrade-lifetime.test.ts +123 -0
- package/tests/preview-upgrade.test.ts +277 -0
- package/tests/preview-vite.test.ts +296 -0
- package/tests/preview.test.ts +406 -0
- package/tests/preview1-listener-browser.ts +136 -0
- package/tests/preview1-listener-lifecycle.test.ts +55 -0
- package/tests/preview1-listener-module.ts +12 -0
- package/tests/preview1-listener.test.ts +430 -0
- package/tests/preview1-network-launch.test.ts +251 -0
- package/tests/preview1-network-lifetime.test.ts +71 -0
- package/tests/preview1-socket-libc.test.ts +65 -0
- package/tests/preview1-socket-support.ts +213 -0
- package/tests/preview1-socket.test.ts +506 -0
- package/tests/preview1-worker-entry.test.ts +42 -0
- package/tests/preview1-worker-startup.test.ts +74 -0
- package/tests/process-abi.test.ts +1568 -0
- package/tests/process-access.test.ts +653 -0
- package/tests/process-admission.test.ts +413 -0
- package/tests/process-cell-clone-browser.test.ts +24 -0
- package/tests/process-cell-clone-browser.ts +239 -0
- package/tests/process-cell-clone.test.ts +39 -0
- package/tests/process-control.test.ts +166 -0
- package/tests/process-core.test.ts +1528 -0
- package/tests/process-cwd.test.ts +237 -0
- package/tests/process-directory-rejection.test.ts +149 -0
- package/tests/process-entry.test.ts +12 -0
- package/tests/process-execve.test.ts +677 -0
- package/tests/process-host-failure.test.ts +149 -0
- package/tests/process-identity.test.ts +482 -0
- package/tests/process-job.test.ts +504 -0
- package/tests/process-linux-signals.test.ts +535 -0
- package/tests/process-loader-retry.test.ts +137 -0
- package/tests/process-lookup.test.ts +408 -0
- package/tests/process-memory-admission-rollback.test.ts +218 -0
- package/tests/process-navigation-observer.test.ts +362 -0
- package/tests/process-navigation-observer.ts +707 -0
- package/tests/process-observation-boundary.test.ts +103 -0
- package/tests/process-observation-lifecycle.test.ts +279 -0
- package/tests/process-observation-root.test.ts +498 -0
- package/tests/process-observation-standalone.test.ts +236 -0
- package/tests/process-observation.test.ts +243 -0
- package/tests/process-outcome.test.ts +222 -0
- package/tests/process-pipe-recycling.test.ts +336 -0
- package/tests/process-poll-idle.test.ts +345 -0
- package/tests/process-quiescence.test.ts +317 -0
- package/tests/process-recycling-browser-runner-control.ts +103 -0
- package/tests/process-recycling-browser-runner.test.ts +385 -0
- package/tests/process-recycling-browser-runner.ts +410 -0
- package/tests/process-recycling-browser.ts +1720 -0
- package/tests/process-replacement.test.ts +1950 -0
- package/tests/process-root-navigation-diagnostic.test.ts +1146 -0
- package/tests/process-root-navigation-diagnostic.ts +1291 -0
- package/tests/process-signal-poll.test.ts +168 -0
- package/tests/process-spawn-diagnostic.test.ts +388 -0
- package/tests/process-spawn-errno.test.ts +265 -0
- package/tests/process-start-browser-runner.ts +90 -0
- package/tests/process-start-browser.ts +181 -0
- package/tests/process-start-diagnostics.test.ts +301 -0
- package/tests/process-start-failed.test.ts +336 -0
- package/tests/process-start-status.test.ts +512 -0
- package/tests/process-startup-review.test.ts +507 -0
- package/tests/process-worker-lifetime.test.ts +125 -0
- package/tests/process-worker-ownership.test.ts +3153 -0
- package/tests/program-admission-metadata.test.ts +131 -0
- package/tests/program-build-tools.test.ts +271 -0
- package/tests/program-host-command-debt.ts +48 -0
- package/tests/program-host-command-fixture.ts +108 -0
- package/tests/program-host-command-signals.test.ts +271 -0
- package/tests/program-host-command-types.test.ts +46 -0
- package/tests/program-host-command.test.ts +688 -0
- package/tests/program-loading-api.test.ts +475 -0
- package/tests/program-manifest-lookup.test.ts +129 -0
- package/tests/program-script-loading.test.ts +174 -0
- package/tests/program-session-example.test.ts +313 -0
- package/tests/program-url-download.test.ts +380 -0
- package/tests/programs-install-termination-debt.ts +146 -0
- package/tests/programs-install-termination.test.ts +51 -0
- package/tests/programs-install.test.ts +388 -0
- package/tests/public-workspace-endurance.test.ts +244 -0
- package/tests/publication-browser-runner.test.ts +27 -0
- package/tests/publication-browser-runner.ts +96 -0
- package/tests/publication-browser.ts +913 -0
- package/tests/publication-channel-observer.test.ts +92 -0
- package/tests/publication-checkpoint-contract.test.ts +306 -0
- package/tests/publication-command.ts +35 -0
- package/tests/publication-cross-tab-assets.ts +38 -0
- package/tests/publication-cross-tab-browser-runner.ts +37 -0
- package/tests/publication-cross-tab-browser.ts +966 -0
- package/tests/publication-cross-tab-command.ts +1003 -0
- package/tests/publication-cross-tab-host.ts +89 -0
- package/tests/publication-cross-tab-inventory.ts +53 -0
- package/tests/publication-durable-metadata.test.ts +507 -0
- package/tests/publication-limits-contract.test.ts +106 -0
- package/tests/publication-memory-accounting.test.ts +575 -0
- package/tests/readiness-stream.test.ts +405 -0
- package/tests/readiness.test.ts +90 -0
- package/tests/recovery-r42-browser-runner.ts +330 -0
- package/tests/recovery-r42.test.ts +23 -0
- package/tests/reservation-waste.test.ts +243 -0
- package/tests/resident-construction.test.ts +663 -0
- package/tests/root-continuity-browser-runner.ts +62 -0
- package/tests/root-continuity-browser.ts +269 -0
- package/tests/root-continuity-command.ts +23 -0
- package/tests/root-continuity-source-parity.test.ts +77 -0
- package/tests/root-continuity.test.ts +196 -0
- package/tests/root-return-gc.test.ts +36 -0
- package/tests/running-member-reuse-browser-runner.ts +123 -0
- package/tests/running-member-reuse-browser.ts +383 -0
- package/tests/runtime-budget-ownership.test.ts +38 -0
- package/tests/runtime-display-fence.test.ts +20 -0
- package/tests/runtime-disposal-signal-order.test.ts +25 -0
- package/tests/runtime-facade.test.ts +2004 -0
- package/tests/runtime-filesystem-close-debt.test.ts +38 -0
- package/tests/runtime-network-fence.test.ts +8 -0
- package/tests/runtime-network.test.ts +456 -0
- package/tests/runtime-process-context.test.ts +349 -0
- package/tests/runtime-request-pool.test.ts +83 -0
- package/tests/runtime-size.test.ts +102 -0
- package/tests/runtime-startup-proof.test.ts +86 -0
- package/tests/runtime-startup-proof.ts +25 -0
- package/tests/runtime-startup.test.ts +299 -0
- package/tests/runtime-terminals.test.ts +496 -0
- package/tests/safe-staging-browser-runner.ts +22 -0
- package/tests/safe-staging-browser.ts +1224 -0
- package/tests/safe-staging-fixture-hooks.test.ts +63 -0
- package/tests/safe-staging-native.test.ts +29 -0
- package/tests/safe-staging-native.ts +32 -0
- package/tests/safe-staging-runner-contract.test.ts +30 -0
- package/tests/safe-staging.test.ts +96 -0
- package/tests/search-executor-browser-runner.ts +34 -0
- package/tests/search-executor-browser.ts +614 -0
- package/tests/search-file-reader.test.ts +58 -0
- package/tests/search-grep-plan.test.ts +364 -0
- package/tests/search-matcher-differential.test.ts +187 -0
- package/tests/search-matcher.test.ts +173 -0
- package/tests/search-operand-plan.test.ts +30 -0
- package/tests/search-program-browser-runner.ts +146 -0
- package/tests/search-program-browser.ts +388 -0
- package/tests/search-rg-plan.test.ts +407 -0
- package/tests/search-run.test.ts +366 -0
- package/tests/search-source.test.ts +129 -0
- package/tests/sender-admission.test.ts +251 -0
- package/tests/shared-caller-admission.test.ts +121 -0
- package/tests/shared-caller-host-exec.test.ts +119 -0
- package/tests/shared-control-pipes.test.ts +37 -0
- package/tests/shared-guest-backing.test.ts +746 -0
- package/tests/shared-memory-admission.test.ts +203 -0
- package/tests/shared-memory-browser-bundle.test.ts +62 -0
- package/tests/shared-memory-input.test.ts +79 -0
- package/tests/shared-reservation-coverage.test.ts +15 -0
- package/tests/spawn-error-context.test.ts +38 -0
- package/tests/stable-memory-reader.test.ts +26 -0
- package/tests/start-command.test.ts +109 -0
- package/tests/start-failure-quiet-browser.ts +333 -0
- package/tests/start-failure-quiet.test.ts +24 -0
- package/tests/startup-diagnostic-browser.ts +192 -0
- package/tests/startup-diagnostic.test.ts +43 -0
- package/tests/startup-pool-browser.ts +173 -0
- package/tests/stop-order-browser-runner.ts +135 -0
- package/tests/stop-order-browser.ts +166 -0
- package/tests/storage-allocation.ts +41 -0
- package/tests/storage-browser-helpers.ts +46 -0
- package/tests/storage-browser-runner.ts +205 -0
- package/tests/storage-browser.ts +2 -0
- package/tests/storage-caller-release.test.ts +82 -0
- package/tests/storage-crash-r2-browser.ts +7 -0
- package/tests/storage-crash-r2-indexeddb.ts +307 -0
- package/tests/storage-crash-r2-opfs.ts +224 -0
- package/tests/storage-crash-r2-scheduler.ts +88 -0
- package/tests/storage-crash-r2-state.ts +132 -0
- package/tests/storage-crash-r2.test.ts +109 -0
- package/tests/storage-lifecycle-marker.ts +5 -0
- package/tests/storage-lifecycle-observer.ts +131 -0
- package/tests/storage-lock-adapter.test.ts +82 -0
- package/tests/storage-lock-browser-runner.ts +1033 -0
- package/tests/storage-lock-browser.ts +321 -0
- package/tests/storage-lock-cases.ts +157 -0
- package/tests/storage-lock-host.ts +103 -0
- package/tests/storage-lock-observation.ts +60 -0
- package/tests/storage-lock-page.ts +18 -0
- package/tests/storage-lock-peer.ts +132 -0
- package/tests/storage-lock-recovery-worker.ts +60 -0
- package/tests/storage-lock-schedules.ts +375 -0
- package/tests/storage-lock-startup.test.ts +73 -0
- package/tests/storage-navigation-diagnostics.test.ts +548 -0
- package/tests/storage-navigation-diagnostics.ts +231 -0
- package/tests/storage-open-worker.ts +18 -0
- package/tests/storage-quota-control.ts +12 -0
- package/tests/storage-quota-r2-browser.ts +548 -0
- package/tests/storage-quota-r2-probes.ts +393 -0
- package/tests/storage-quota-r2.test.ts +17 -0
- package/tests/storage-release-browser.ts +129 -0
- package/tests/storage-release.test.ts +442 -0
- package/tests/storage-suite-contract.test.ts +15 -0
- package/tests/storage.test.ts +520 -0
- package/tests/symlink-sizing.test.ts +226 -0
- package/tests/terminal-control.test.ts +639 -0
- package/tests/terminal-deadholder.test.ts +631 -0
- package/tests/terminal-gate-wake.test.ts +360 -0
- package/tests/terminal-handoff.test.ts +86 -0
- package/tests/terminal-input.test.ts +332 -0
- package/tests/terminal-interrupt-flush.test.ts +554 -0
- package/tests/terminal-output.test.ts +711 -0
- package/tests/terminal-read-fds.test.ts +153 -0
- package/tests/terminal-resolver-worker.test.ts +125 -0
- package/tests/terminal-session.test.ts +1794 -0
- package/tests/thread-admission.test.ts +151 -0
- package/tests/threads-browser-contract.ts +32 -0
- package/tests/threads-browser-guest-worker.ts +12 -0
- package/tests/threads-browser-page.ts +552 -0
- package/tests/threads-browser-runner.test.ts +83 -0
- package/tests/threads-browser-runner.ts +120 -0
- package/tests/threads-browser-service-worker.ts +116 -0
- package/tests/threads-fdstat-admission.test.ts +64 -0
- package/tests/threads-fdstat-authority-worker.ts +65 -0
- package/tests/threads-fdstat-authority.test.ts +81 -0
- package/tests/threads-fdstat.test.ts +304 -0
- package/tests/threads-fixture-inspect.ts +179 -0
- package/tests/threads-fixture-producer.test.ts +97 -0
- package/tests/threads-guest-fixture.ts +204 -0
- package/tests/threads-guest-lane.test.ts +64 -0
- package/tests/threads-guest-memory.test.ts +283 -0
- package/tests/threads-guest-module.ts +95 -0
- package/tests/threads-guest-rust-runner.test.ts +52 -0
- package/tests/threads-guest-rust-runner.ts +142 -0
- package/tests/threads-guest-worker.ts +50 -0
- package/tests/threads-guest.test.ts +305 -0
- package/tests/threads-lifecycle-module.ts +41 -0
- package/tests/threads-lifecycle-waiter.ts +38 -0
- package/tests/threads-lifecycle.test.ts +416 -0
- package/tests/threads-memory-growth.test.ts +188 -0
- package/tests/threads-random-control.ts +170 -0
- package/tests/threads-random.test.ts +23 -0
- package/tests/threads-runtime-authority-worker.ts +63 -0
- package/tests/threads-runtime-browser-runner.ts +119 -0
- package/tests/threads-runtime-browser.ts +622 -0
- package/tests/threads-runtime-cases.ts +38 -0
- package/tests/threads-runtime-cleanup.test.ts +58 -0
- package/tests/threads-runtime-cleanup.ts +46 -0
- package/tests/threads-runtime-control.ts +13 -0
- package/tests/threads-runtime-failure-control.ts +338 -0
- package/tests/threads-runtime-failures.test.ts +116 -0
- package/tests/threads-runtime-fault-bootstrap.ts +1 -0
- package/tests/threads-runtime-fault-conditions.test.ts +35 -0
- package/tests/threads-runtime-fault-control.ts +394 -0
- package/tests/threads-runtime-fault-service.ts +56 -0
- package/tests/threads-runtime-fd-browser.ts +247 -0
- package/tests/threads-runtime-fd-control.ts +6 -0
- package/tests/threads-runtime-fd-descriptors.test.ts +45 -0
- package/tests/threads-runtime-fd-filesystem.ts +41 -0
- package/tests/threads-runtime-fd-module.ts +102 -0
- package/tests/threads-runtime-fd-service.ts +75 -0
- package/tests/threads-runtime-growth-worker.ts +61 -0
- package/tests/threads-runtime-host.ts +32 -0
- package/tests/threads-runtime-late-read-service.ts +46 -0
- package/tests/threads-runtime-modules.ts +132 -0
- package/tests/threads-runtime-regression-controls.ts +386 -0
- package/tests/threads-runtime-regression-modules.ts +242 -0
- package/tests/threads-runtime-safari-packet.ts +285 -0
- package/tests/threads-runtime-safari-runner.test.ts +173 -0
- package/tests/threads-runtime-safari-runner.ts +270 -0
- package/tests/threads-runtime-service-barrier.ts +56 -0
- package/tests/threads-runtime.test.ts +143 -0
- package/tests/threads-safari-runner.ts +159 -0
- package/tests/threads-service-edge.test.ts +93 -0
- package/tests/threads-service-fixture.ts +117 -0
- package/tests/threads-service-host.ts +103 -0
- package/tests/threads-service.test.ts +305 -0
- package/tests/threads-wait-owner.test.ts +169 -0
- package/tests/vfs-continuation.test.ts +337 -0
- package/tests/vfs-guest-buffer.test.ts +31 -0
- package/tests/vfs-harness.test.ts +414 -0
- package/tests/vfs.test.ts +167 -0
- package/tests/wasi-clocks.test.ts +152 -0
- package/tests/wasi-exit.test.ts +74 -0
- package/tests/wasi-libc.test.ts +272 -0
- package/tests/wasi-nonblock-inheritance.test.ts +109 -0
- package/tests/wasi-nonblock.test.ts +181 -0
- package/tests/wasi-path-memory.test.ts +225 -0
- package/tests/wasi-size-admission.test.ts +227 -0
- package/tests/wasm-start-section.test.ts +39 -0
- package/tests/watch-account.test.ts +603 -0
- package/tests/watch-admission.test.ts +211 -0
- package/tests/watch-committed.test.ts +1068 -0
- package/tests/watch-direct-worker.ts +35 -0
- package/tests/watch-registration-reap.test.ts +129 -0
- package/tests/watch-root-runtime.test.ts +313 -0
- package/tests/webkit-diagnostics.ts +125 -0
- package/tests/webkit-error-output.test.ts +118 -0
- package/tests/worker-access.test.ts +331 -0
- package/tests/worker-final-completion.test.ts +434 -0
- package/tests/worker-memory-bootstrap.test.ts +237 -0
- package/tests/worker-memory-broker.test.ts +666 -0
- package/tests/worker-memory.test.ts +210 -0
- package/tests/worker-pipes.test.ts +993 -0
- package/tests/worker-pool.test.ts +88 -0
- package/tests/worker-selected-signal.test.ts +429 -0
- package/tests/workspace-archive-pulls.test.ts +501 -0
- package/tests/workspace-archive.test.ts +1281 -0
- package/tests/workspace-browser.ts +444 -0
- package/tests/workspace-capacity.test.ts +627 -0
- package/tests/workspace-continuity-browser-runner.ts +664 -0
- package/tests/workspace-continuity-checkpoint.test.ts +101 -0
- package/tests/workspace-continuity.test.ts +196 -0
- package/tests/workspace-export-public.test.ts +154 -0
- package/tests/workspace-export.test.ts +1709 -0
- package/tests/workspace-import-admission.test.ts +409 -0
- package/tests/workspace-root-release.test.ts +112 -0
- package/tests/workspace-safari-browser.ts +239 -0
- package/tests/workspace-safari-guest.ts +38 -0
- package/tests/workspace-safari-local.ts +33 -0
- package/tests/workspace-safari-runner.test.ts +298 -0
- package/tests/workspace-search.test.ts +892 -0
- package/tests/workspace-vfs-read-browser.ts +388 -0
- package/tests/workspace-vfs-read-cold-lifecycle.test.ts +236 -0
- package/tests/workspace-vfs-read-cold-readiness.test.ts +97 -0
- package/tests/workspace-vfs-read-dirty.test.ts +119 -0
- package/tests/workspace-vfs-read-races.test.ts +863 -0
- package/tests/workspace-vfs-read-serials.test.ts +124 -0
- package/tests/workspace-vfs-read-shutdown.test.ts +217 -0
- package/tests/workspace-vfs-read-stream.test.ts +878 -0
- package/tests/workspace-vfs-read.test.ts +758 -0
- package/tests/workspace-vfs.test.ts +785 -0
- package/thread/entry.ts +140 -0
- package/thread/guest-bootstrap.ts +12 -0
- package/thread/guest-imports.ts +329 -0
- package/thread/guest-module.ts +6 -0
- package/thread/guest-worker.ts +179 -0
- package/thread/lane.ts +461 -0
- package/thread/protocol.ts +18 -0
- package/thread/runtime-owner.ts +619 -0
- package/thread/runtime-protocol.ts +33 -0
- package/thread/service-worker.ts +95 -0
- package/thread/service.ts +482 -0
- package/tooling/build-network.ts +157 -0
- package/tooling/check-network-rust.ts +59 -0
- package/tooling/check-package-metadata.ts +8 -0
- package/tooling/ci-paths.test.ts +1904 -0
- package/tooling/fixtures/page-runner-error-consumer.ts +124 -0
- package/tooling/gpu-coverage.ts +177 -0
- package/tooling/gpu-desktop-measure.ts +100 -0
- package/tooling/gpu-measure-host.ts +59 -0
- package/tooling/gpu-measure.ts +512 -0
- package/tooling/gpu-size.ts +38 -0
- package/tooling/gpu-stream-layout.ts +268 -0
- package/tooling/gpu-stream-model.ts +106 -0
- package/tooling/gpu-stream.ts +951 -0
- package/tooling/host-interface.ts +107 -0
- package/tooling/network-growth.ts +120 -0
- package/tooling/network-size.ts +73 -0
- package/tooling/network-source-smoke.ts +86 -0
- package/tooling/network-translator/bun.lock +15 -0
- package/tooling/network-translator/package.json +7 -0
- package/tooling/network-translator.test.ts +117 -0
- package/tooling/network-translator.ts +147 -0
- package/tooling/package-inputs.ts +25 -0
- package/tooling/prepare-allocation-reference.ts +32 -0
- package/tooling/private-authority.ts +1445 -0
- package/tooling/program/program-build-tools.ts +440 -0
- package/tooling/program/program-derivation.ts +175 -0
- package/tooling/program/program-optimize.ts +330 -0
- package/tooling/program/program-transformer.json +1 -0
- package/tooling/program-tools-package.ts +77 -0
- package/tooling/quality-probes.ts +101 -0
- package/tooling/runtime-size.ts +42 -0
- package/tooling/shared-reservations.ts +57 -0
- package/tooling/storage-crash-r2-mutations.ts +59 -0
- package/tooling/storage-crash-r2.ts +89 -0
- package/tooling/storage-quota-r2.ts +141 -0
- package/tooling/tarball-smoke.ts +556 -0
- package/tooling/typescript-source.test.ts +38 -0
- package/tooling/typescript-source.ts +47 -0
- package/tooling/vfs-benchmark.ts +903 -0
- package/tooling/vfs-browser.ts +320 -0
- package/tooling/vfs-continuation.ts +313 -0
- package/tooling/vfs-guest.ts +235 -0
- package/tooling/vfs-score-config.ts +64 -0
- package/tooling/vfs-score.ts +406 -0
- package/tooling/vfs-startup.ts +21 -0
- package/tooling/vfs-workloads.ts +382 -0
- package/tooling/workspace-safari-runner.ts +313 -0
|
@@ -0,0 +1,3153 @@
|
|
|
1
|
+
import { fixtureSpawnRequest as request } from "./fixtures/spawn-request.ts";
|
|
2
|
+
|
|
3
|
+
import { MemFS } from "../fs/memory.js";
|
|
4
|
+
|
|
5
|
+
import { afterEach, expect, test } from "bun:test";
|
|
6
|
+
import {
|
|
7
|
+
DescriptorTable,
|
|
8
|
+
OpenDescription,
|
|
9
|
+
type Descriptor,
|
|
10
|
+
type Resource,
|
|
11
|
+
type Stream,
|
|
12
|
+
} from "../core/descriptors.js";
|
|
13
|
+
|
|
14
|
+
type ProcessSupervisor = import("../proc/supervisor.js").ProcessSupervisor;
|
|
15
|
+
|
|
16
|
+
import type {
|
|
17
|
+
WorkerDescriptorCodec,
|
|
18
|
+
WorkerProcessMessage,
|
|
19
|
+
WorkerProcessTransport,
|
|
20
|
+
} from "../proc/worker-client.js";
|
|
21
|
+
|
|
22
|
+
import type { ProcessContext, ProcessHandle } from "../proc/types.js";
|
|
23
|
+
import { isolatedProcess } from "./fixtures/isolated-process.js";
|
|
24
|
+
|
|
25
|
+
const isolated = await isolatedProcess();
|
|
26
|
+
const Atomics = isolated.atomics;
|
|
27
|
+
const { ProcessABI } = isolated.load<typeof import("../proc/abi.js")>("abi");
|
|
28
|
+
const {
|
|
29
|
+
collectDirectoryProcess,
|
|
30
|
+
collectDirectoryJob,
|
|
31
|
+
directorySlots,
|
|
32
|
+
directoryJobs,
|
|
33
|
+
directoryJob,
|
|
34
|
+
directoryProcesses,
|
|
35
|
+
directoryGroups,
|
|
36
|
+
findDirectoryJob,
|
|
37
|
+
helpDirectoryJobs,
|
|
38
|
+
reserveDirectoryProcess,
|
|
39
|
+
} = isolated.load<typeof import("../proc/directory.js")>("directory");
|
|
40
|
+
const {
|
|
41
|
+
packedControl,
|
|
42
|
+
controlLoad,
|
|
43
|
+
controlStore,
|
|
44
|
+
controlCas,
|
|
45
|
+
controlExchange,
|
|
46
|
+
controlAdd,
|
|
47
|
+
controlWait,
|
|
48
|
+
controlNotify,
|
|
49
|
+
} = isolated.load<typeof import("../proc/control.js")>("control");
|
|
50
|
+
const { ExecutableRegistry } = isolated.load<typeof import("../proc/registry.js")>("registry");
|
|
51
|
+
const { ProcessSupervisor } = isolated.load<typeof import("../proc/supervisor.js")>("supervisor");
|
|
52
|
+
const { SignalDisposition, setSignalDisposition } =
|
|
53
|
+
isolated.load<typeof import("../proc/signals.js")>("signals");
|
|
54
|
+
const { captureNativeReturn } =
|
|
55
|
+
isolated.load<typeof import("../proc/observation.js")>("observation");
|
|
56
|
+
const { claimOutcome, readOutcome } = isolated.load<typeof import("../proc/outcome.js")>("outcome");
|
|
57
|
+
const { WorkerProcessBroker } =
|
|
58
|
+
isolated.load<typeof import("../proc/worker-broker.js")>("worker-broker");
|
|
59
|
+
const {
|
|
60
|
+
createWorkerProcessTransport,
|
|
61
|
+
confirmWorkerProcessJob,
|
|
62
|
+
installWorkerBindings,
|
|
63
|
+
WorkerProcessClient,
|
|
64
|
+
workerProcessState,
|
|
65
|
+
} = isolated.load<typeof import("../proc/worker-client.js")>("worker-client");
|
|
66
|
+
const { WorkerPipeHost, createWorkerPipeCodec } =
|
|
67
|
+
isolated.load<typeof import("../proc/worker-pipes.js")>("worker-pipes");
|
|
68
|
+
const { ProcessErrno, ProcessError } = isolated.load<typeof import("../proc/types.js")>("types");
|
|
69
|
+
|
|
70
|
+
const cleanups: (() => void)[] = [];
|
|
71
|
+
afterEach(() => {
|
|
72
|
+
while (cleanups.length) cleanups.pop()!();
|
|
73
|
+
});
|
|
74
|
+
const emptyModule = new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0]));
|
|
75
|
+
|
|
76
|
+
function expectErrno(operation: () => unknown, errno: number): void {
|
|
77
|
+
let error: unknown;
|
|
78
|
+
try {
|
|
79
|
+
operation();
|
|
80
|
+
} catch (caught) {
|
|
81
|
+
error = caught;
|
|
82
|
+
}
|
|
83
|
+
expect(error).toMatchObject({ name: "ProcessError", errno });
|
|
84
|
+
}
|
|
85
|
+
interface Token {
|
|
86
|
+
state: SharedArrayBuffer;
|
|
87
|
+
lifetime: SharedArrayBuffer;
|
|
88
|
+
pid: number;
|
|
89
|
+
kind: "pipe" | "directory";
|
|
90
|
+
}
|
|
91
|
+
function fakeCodec() {
|
|
92
|
+
const states = new WeakMap<Resource, SharedArrayBuffer>();
|
|
93
|
+
const release = (token: Token) => {
|
|
94
|
+
if (controlCas(new Int32Array(token.lifetime), 0, 0, 1) !== 0) return;
|
|
95
|
+
const state = new Int32Array(token.state);
|
|
96
|
+
Atomics.sub(state, 0, 1);
|
|
97
|
+
Atomics.add(state, 1, 1);
|
|
98
|
+
};
|
|
99
|
+
const resource = (token: Token): Resource => {
|
|
100
|
+
const value: Resource =
|
|
101
|
+
token.kind === "directory"
|
|
102
|
+
? { kind: "directory", handle: 42 }
|
|
103
|
+
: {
|
|
104
|
+
kind: "pipe",
|
|
105
|
+
read: () => 0,
|
|
106
|
+
write: (chunks) => chunks.reduce((n, chunk) => n + chunk.length, 0),
|
|
107
|
+
readiness: () => ({ readable: true, writable: true, hangup: false }),
|
|
108
|
+
forProcess: () => value as Stream,
|
|
109
|
+
revoke: () => {
|
|
110
|
+
Atomics.add(new Int32Array(token.state), 2, 1);
|
|
111
|
+
},
|
|
112
|
+
close: () => release(token),
|
|
113
|
+
};
|
|
114
|
+
states.set(value, token.state);
|
|
115
|
+
return value;
|
|
116
|
+
};
|
|
117
|
+
const codec: WorkerDescriptorCodec = {
|
|
118
|
+
export(source: Descriptor, pid: number) {
|
|
119
|
+
const state = states.get(source.resource);
|
|
120
|
+
if (!state) throw new Error("unknown resource");
|
|
121
|
+
if (source.resource.kind !== "pipe" && source.resource.kind !== "directory")
|
|
122
|
+
throw new Error("unsupported test resource");
|
|
123
|
+
Atomics.add(new Int32Array(state), 0, 1);
|
|
124
|
+
return {
|
|
125
|
+
state,
|
|
126
|
+
pid,
|
|
127
|
+
lifetime: new SharedArrayBuffer(4),
|
|
128
|
+
kind: source.resource.kind,
|
|
129
|
+
} satisfies Token;
|
|
130
|
+
},
|
|
131
|
+
import(value) {
|
|
132
|
+
const token = value as Token;
|
|
133
|
+
return new OpenDescription(resource(token), () => release(token));
|
|
134
|
+
},
|
|
135
|
+
discard(value) {
|
|
136
|
+
release(value as Token);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
codec,
|
|
141
|
+
source(descriptors: DescriptorTable, kind: Token["kind"] = "pipe") {
|
|
142
|
+
const state = new SharedArrayBuffer(12);
|
|
143
|
+
controlStore(new Int32Array(state), 0, 1);
|
|
144
|
+
const token = { state, lifetime: new SharedArrayBuffer(4), pid: 1, kind };
|
|
145
|
+
const fd = descriptors.open(resource(token), 127n, 63n, () => release(token));
|
|
146
|
+
return { fd, counts: new Int32Array(state) };
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function fixture(
|
|
151
|
+
options: {
|
|
152
|
+
capacity?: number;
|
|
153
|
+
launch?(context: ProcessContext): ProcessHandle | Promise<ProcessHandle>;
|
|
154
|
+
activate?: (supervisor: ProcessSupervisor) => Promise<ProcessSupervisor>;
|
|
155
|
+
beforeActivation?(supervisor: ProcessSupervisor): void;
|
|
156
|
+
terminate?(): void | Promise<void>;
|
|
157
|
+
quiesce?(pid: number): void | Promise<void>;
|
|
158
|
+
onError?(error: unknown): void;
|
|
159
|
+
rejectedQuiesce?(pid: number): void | Promise<void>;
|
|
160
|
+
} = {},
|
|
161
|
+
) {
|
|
162
|
+
const transport = createWorkerProcessTransport({ capacity: options.capacity });
|
|
163
|
+
const state = workerProcessState(transport);
|
|
164
|
+
const registry = new ExecutableRegistry();
|
|
165
|
+
registry.register("fixture", { module: emptyModule, adapter: "preview1" });
|
|
166
|
+
const contexts = new Map<number, ProcessContext>();
|
|
167
|
+
const supervisor = new ProcessSupervisor({
|
|
168
|
+
registry,
|
|
169
|
+
onError: options.onError,
|
|
170
|
+
quiesce: options.quiesce,
|
|
171
|
+
launch(context) {
|
|
172
|
+
contexts.set(context.pid, context);
|
|
173
|
+
return (
|
|
174
|
+
options.launch?.(context) ?? {
|
|
175
|
+
terminate() {
|
|
176
|
+
return options.terminate?.();
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
supervisor.createRoot({
|
|
183
|
+
pid: state.pid,
|
|
184
|
+
job: state.job,
|
|
185
|
+
observation: transport,
|
|
186
|
+
...state.signals,
|
|
187
|
+
});
|
|
188
|
+
options.beforeActivation?.(supervisor);
|
|
189
|
+
const { codec, source } = fakeCodec();
|
|
190
|
+
const messages: WorkerProcessMessage[] = [];
|
|
191
|
+
const revoked: number[] = [];
|
|
192
|
+
const broker = new WorkerProcessBroker({
|
|
193
|
+
supervisor: () => options.activate?.(supervisor) ?? Promise.resolve(supervisor),
|
|
194
|
+
codec,
|
|
195
|
+
quiesce: options.rejectedQuiesce,
|
|
196
|
+
});
|
|
197
|
+
broker.adoptRoot(transport);
|
|
198
|
+
cleanups.push(() => {
|
|
199
|
+
broker.dispose();
|
|
200
|
+
supervisor.dispose();
|
|
201
|
+
});
|
|
202
|
+
const client = (value: WorkerProcessTransport) => {
|
|
203
|
+
const descriptors = new DescriptorTable();
|
|
204
|
+
cleanups.push(() => descriptors.dispose());
|
|
205
|
+
return new WorkerProcessClient({
|
|
206
|
+
transport: value,
|
|
207
|
+
descriptors,
|
|
208
|
+
codec,
|
|
209
|
+
postMessage(message) {
|
|
210
|
+
messages.push(structuredClone(message));
|
|
211
|
+
},
|
|
212
|
+
revokeProcess(pid) {
|
|
213
|
+
revoked.push(pid);
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
const root = client(transport);
|
|
218
|
+
return {
|
|
219
|
+
transport,
|
|
220
|
+
root,
|
|
221
|
+
broker,
|
|
222
|
+
supervisor,
|
|
223
|
+
contexts,
|
|
224
|
+
messages,
|
|
225
|
+
source,
|
|
226
|
+
client,
|
|
227
|
+
codec,
|
|
228
|
+
revoked,
|
|
229
|
+
async flush() {
|
|
230
|
+
while (messages.length) await broker.handle(messages.shift()!);
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
test("worker spawn synchronously retains arbitrary bindings across lazy activation and immediate parent close", async () => {
|
|
236
|
+
let activate!: (supervisor: ProcessSupervisor) => void;
|
|
237
|
+
const loading = new Promise<ProcessSupervisor>((resolve) => {
|
|
238
|
+
activate = resolve;
|
|
239
|
+
});
|
|
240
|
+
const f = fixture({ activate: () => loading });
|
|
241
|
+
const { fd, counts } = f.source(f.root.options.descriptors, "directory");
|
|
242
|
+
const pid = f.root.spawn(1, request({ fds: [{ child: 19, parent: fd }] }));
|
|
243
|
+
f.root.options.descriptors.close(fd);
|
|
244
|
+
expect(counts[0]).toBe(1);
|
|
245
|
+
expect(f.root.wait(1, pid)).toBeNull();
|
|
246
|
+
expect(f.contexts.size).toBe(0);
|
|
247
|
+
const admitted = f.flush();
|
|
248
|
+
activate(f.supervisor);
|
|
249
|
+
await admitted;
|
|
250
|
+
await f.supervisor.start(pid);
|
|
251
|
+
expect(f.contexts.get(pid)!.descriptors.get(19)!.resource.kind).toBe("directory");
|
|
252
|
+
const child = f.client(structuredClone(f.broker.get(pid)!));
|
|
253
|
+
child.installBindings();
|
|
254
|
+
expect(child.options.descriptors.get(19)!.rightsBase).toBe(127n);
|
|
255
|
+
expect(child.options.descriptors.get(19)!.description.references).toBe(1);
|
|
256
|
+
child.exit(7);
|
|
257
|
+
expect(f.root.wait(1, pid)).toBeNull();
|
|
258
|
+
await f.flush();
|
|
259
|
+
expect(f.root.wait(1, pid)).toEqual({ kind: "exited", code: 7, status: 7 });
|
|
260
|
+
expect(counts[0]).toBe(0);
|
|
261
|
+
expect(counts[1]).toBe(2);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test("the typed Worker field reaches the adapter as an owned copy, and only an object counts", async () => {
|
|
265
|
+
const f = fixture();
|
|
266
|
+
const worker: Record<string, unknown> = { resourceLimits: {} };
|
|
267
|
+
const thread = f.root.spawn(1, request({ worker }));
|
|
268
|
+
worker.resourceLimits = "changed after the synchronous spawn";
|
|
269
|
+
const ordinary = f.root.spawn(1, request());
|
|
270
|
+
const malformed = [null, 1, "x", true].map((value) =>
|
|
271
|
+
f.root.spawn(1, request({ worker: value as never })),
|
|
272
|
+
);
|
|
273
|
+
await f.flush();
|
|
274
|
+
const started = malformed.concat([thread, ordinary]);
|
|
275
|
+
for (const pid of started) await f.supervisor.start(pid);
|
|
276
|
+
expect(f.contexts.get(thread)!.request.worker).toEqual({ resourceLimits: {} });
|
|
277
|
+
for (const pid of malformed.concat([ordinary]))
|
|
278
|
+
expect(f.contexts.get(pid)!.request).not.toHaveProperty("worker");
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("spawned pipe writers survive parent exit before the child worker starts", () => {
|
|
282
|
+
const transport = createWorkerProcessTransport({ capacity: 16 });
|
|
283
|
+
const spawnMessages: WorkerProcessMessage[] = [];
|
|
284
|
+
const pipes = new WorkerPipeHost({ transport, postMessage() {} });
|
|
285
|
+
const [reader, writer] = pipes.createPipe();
|
|
286
|
+
const rootDescriptors = new DescriptorTable();
|
|
287
|
+
const readFd = rootDescriptors.open(reader, 1n, 1n),
|
|
288
|
+
writeFd = rootDescriptors.open(writer, 1n, 1n);
|
|
289
|
+
const codec = createWorkerPipeCodec();
|
|
290
|
+
const root = new WorkerProcessClient({
|
|
291
|
+
transport,
|
|
292
|
+
descriptors: rootDescriptors,
|
|
293
|
+
codec,
|
|
294
|
+
postMessage(message) {
|
|
295
|
+
spawnMessages.push(message);
|
|
296
|
+
},
|
|
297
|
+
prepareSpawn(pid) {
|
|
298
|
+
pipes.registry.registerProcess(pid);
|
|
299
|
+
return { cancel: () => pipes.registry.collectProcess(pid) };
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
try {
|
|
303
|
+
// The root launches a leader, which is the parent whose worker will exit before its child
|
|
304
|
+
// starts. The root reader remains alive as an observer of the leader's inherited writer.
|
|
305
|
+
const leaderPid = root.spawn(1, request({ job: -1, fds: [{ child: 1, parent: writeFd }] }));
|
|
306
|
+
const leaderTransport = spawnMessages[0]!.transport;
|
|
307
|
+
const leaderDescriptors = new DescriptorTable();
|
|
308
|
+
try {
|
|
309
|
+
const leader = new WorkerProcessClient({
|
|
310
|
+
transport: leaderTransport,
|
|
311
|
+
descriptors: leaderDescriptors,
|
|
312
|
+
codec,
|
|
313
|
+
postMessage(message) {
|
|
314
|
+
spawnMessages.push(message);
|
|
315
|
+
},
|
|
316
|
+
prepareSpawn(pid) {
|
|
317
|
+
pipes.registry.registerProcess(pid);
|
|
318
|
+
return { cancel: () => pipes.registry.collectProcess(pid) };
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
leader.installBindings();
|
|
322
|
+
rootDescriptors.close(writeFd);
|
|
323
|
+
const childPid = leader.spawn(
|
|
324
|
+
leaderPid,
|
|
325
|
+
request({ job: workerProcessState(leaderTransport).job, fds: [{ child: 1, parent: 1 }] }),
|
|
326
|
+
);
|
|
327
|
+
expect(childPid).toBeGreaterThan(leaderPid);
|
|
328
|
+
// Parent exit closes its descriptor only after spawn returned; the child reservation already
|
|
329
|
+
// owns a distinct writer ring, so the observer must see AGAIN rather than premature EOF.
|
|
330
|
+
leaderDescriptors.dispose();
|
|
331
|
+
const pending = new Uint8Array(1);
|
|
332
|
+
expect(reader.tryRead([pending])).toBe(-6);
|
|
333
|
+
const childTransport = spawnMessages[1]!.transport;
|
|
334
|
+
const childDescriptors = new DescriptorTable();
|
|
335
|
+
try {
|
|
336
|
+
expect(workerProcessState(childTransport).pid).toBe(childPid);
|
|
337
|
+
installWorkerBindings(childTransport, childDescriptors, codec);
|
|
338
|
+
childDescriptors.close(1);
|
|
339
|
+
} finally {
|
|
340
|
+
childDescriptors.dispose();
|
|
341
|
+
}
|
|
342
|
+
expect(reader.tryRead([pending])).toBe(0);
|
|
343
|
+
} finally {
|
|
344
|
+
leaderDescriptors.dispose();
|
|
345
|
+
}
|
|
346
|
+
} finally {
|
|
347
|
+
rootDescriptors.close(readFd);
|
|
348
|
+
rootDescriptors.dispose();
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test("worker spawn validates both fd bindings within the signed WASM success range before exporting", async () => {
|
|
353
|
+
const f = fixture();
|
|
354
|
+
const table = f.root.options.descriptors;
|
|
355
|
+
const { fd, counts } = f.source(table);
|
|
356
|
+
for (const invalid of [0x80000000, 0xffffffff, -1, 1.5, NaN]) {
|
|
357
|
+
for (const binding of [
|
|
358
|
+
{ child: invalid, parent: fd },
|
|
359
|
+
{ child: 3, parent: invalid },
|
|
360
|
+
]) {
|
|
361
|
+
let error: unknown;
|
|
362
|
+
try {
|
|
363
|
+
f.root.spawn(1, request({ fds: [binding] }));
|
|
364
|
+
} catch (caught) {
|
|
365
|
+
error = caught;
|
|
366
|
+
}
|
|
367
|
+
expect(error).toMatchObject({ name: "ProcessError", errno: 28 });
|
|
368
|
+
expect(counts[0]).toBe(1);
|
|
369
|
+
expect(f.messages.length).toBe(0);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
table.inherit(0x7fffffff, table.get(fd)!);
|
|
373
|
+
const pid = f.root.spawn(1, request({ fds: [{ child: 0x7fffffff, parent: 0x7fffffff }] }));
|
|
374
|
+
await f.flush();
|
|
375
|
+
const child = f.client(f.broker.get(pid)!);
|
|
376
|
+
child.installBindings();
|
|
377
|
+
const duplicate = child.options.descriptors.dup(0x7fffffff);
|
|
378
|
+
expect(duplicate).toBeGreaterThanOrEqual(0);
|
|
379
|
+
expect(duplicate).toBeLessThanOrEqual(0x7fffffff);
|
|
380
|
+
expect(child.options.descriptors.get(duplicate)!.description).toBe(
|
|
381
|
+
child.options.descriptors.get(0x7fffffff)!.description,
|
|
382
|
+
);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
test("duplicate inherited bindings share one exported lifetime and one child description", async () => {
|
|
386
|
+
const f = fixture();
|
|
387
|
+
const { fd, counts } = f.source(f.root.options.descriptors);
|
|
388
|
+
const alias = f.root.options.descriptors.dup(fd);
|
|
389
|
+
const pid = f.root.spawn(
|
|
390
|
+
1,
|
|
391
|
+
request({
|
|
392
|
+
fds: [
|
|
393
|
+
{ child: 4, parent: fd },
|
|
394
|
+
{ child: 77, parent: alias },
|
|
395
|
+
],
|
|
396
|
+
}),
|
|
397
|
+
);
|
|
398
|
+
expect(f.messages[0]!.transport.resources.length).toBe(1);
|
|
399
|
+
f.root.options.descriptors.close(fd);
|
|
400
|
+
f.root.options.descriptors.close(alias);
|
|
401
|
+
expect(counts[0]).toBe(1);
|
|
402
|
+
await f.flush();
|
|
403
|
+
await f.supervisor.start(pid);
|
|
404
|
+
const child = f.client(structuredClone(f.broker.get(pid)!));
|
|
405
|
+
child.installBindings();
|
|
406
|
+
const table = child.options.descriptors;
|
|
407
|
+
expect(table.get(4)!.description).toBe(table.get(77)!.description);
|
|
408
|
+
table.close(4);
|
|
409
|
+
expect(counts[0]).toBe(1);
|
|
410
|
+
table.close(77);
|
|
411
|
+
expect(counts[0]).toBe(0);
|
|
412
|
+
child.exit(0);
|
|
413
|
+
await f.flush();
|
|
414
|
+
expect(counts[1]).toBe(2);
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
test("partial inherited binding import rolls back descriptors and releases each imported lifetime once", () => {
|
|
418
|
+
const transport = createWorkerProcessTransport();
|
|
419
|
+
transport.bindings = [
|
|
420
|
+
{ fd: 17, reference: 0, rightsBase: 1n, rightsInheriting: 0n },
|
|
421
|
+
{ fd: 31, reference: 1, rightsBase: 1n, rightsInheriting: 0n },
|
|
422
|
+
];
|
|
423
|
+
transport.resources = ["retained", "reject"];
|
|
424
|
+
const descriptors = new DescriptorTable();
|
|
425
|
+
const stream: Stream = {
|
|
426
|
+
kind: "terminal",
|
|
427
|
+
read: () => 0,
|
|
428
|
+
write: () => 0,
|
|
429
|
+
readiness: () => ({ readable: false, writable: true, hangup: false }),
|
|
430
|
+
};
|
|
431
|
+
let releases = 0;
|
|
432
|
+
const codec: WorkerDescriptorCodec = {
|
|
433
|
+
import(token) {
|
|
434
|
+
if (token === "reject") throw new TypeError("binding rejected");
|
|
435
|
+
return new OpenDescription(stream, () => {
|
|
436
|
+
releases++;
|
|
437
|
+
});
|
|
438
|
+
},
|
|
439
|
+
export() {
|
|
440
|
+
throw new Error("unexpected export");
|
|
441
|
+
},
|
|
442
|
+
discard() {},
|
|
443
|
+
};
|
|
444
|
+
try {
|
|
445
|
+
expect(() => installWorkerBindings(transport, descriptors, codec)).toThrow(TypeError);
|
|
446
|
+
expect(descriptors.get(17)).toBeUndefined();
|
|
447
|
+
expect(descriptors.get(31)).toBeUndefined();
|
|
448
|
+
expect(releases).toBe(1);
|
|
449
|
+
} finally {
|
|
450
|
+
descriptors.dispose();
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
test("binding rollback preserves complete preopen metadata after a later install fails", () => {
|
|
455
|
+
const transport = createWorkerProcessTransport();
|
|
456
|
+
transport.bindings = [
|
|
457
|
+
{ fd: 0, reference: 0, rightsBase: 1n, rightsInheriting: 0n },
|
|
458
|
+
{ fd: 31, reference: 1, rightsBase: 1n, rightsInheriting: 0n },
|
|
459
|
+
];
|
|
460
|
+
transport.resources = ["first", "second"];
|
|
461
|
+
class FailingTable extends DescriptorTable {
|
|
462
|
+
private installs = 0;
|
|
463
|
+
override inherit(fd: number, source: Descriptor): void {
|
|
464
|
+
if (++this.installs === 2) throw new Error("binding install failed");
|
|
465
|
+
super.inherit(fd, source);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
const descriptors = new FailingTable();
|
|
469
|
+
const preopen = { kind: "directory" as const, handle: 1 };
|
|
470
|
+
descriptors.open(preopen, 7n, 9n, undefined, "/");
|
|
471
|
+
const stream: Stream = {
|
|
472
|
+
kind: "terminal",
|
|
473
|
+
read: () => 0,
|
|
474
|
+
write: () => 0,
|
|
475
|
+
readiness: () => ({ readable: false, writable: true, hangup: false }),
|
|
476
|
+
};
|
|
477
|
+
let releases = 0;
|
|
478
|
+
const codec: WorkerDescriptorCodec = {
|
|
479
|
+
import() {
|
|
480
|
+
return new OpenDescription(stream, () => {
|
|
481
|
+
releases++;
|
|
482
|
+
});
|
|
483
|
+
},
|
|
484
|
+
export() {
|
|
485
|
+
throw new Error("unexpected export");
|
|
486
|
+
},
|
|
487
|
+
discard() {},
|
|
488
|
+
};
|
|
489
|
+
try {
|
|
490
|
+
expect(() => installWorkerBindings(transport, descriptors, codec)).toThrow(
|
|
491
|
+
"binding install failed",
|
|
492
|
+
);
|
|
493
|
+
expect(descriptors.get(0)?.preopen).toBe("/");
|
|
494
|
+
expect(descriptors.get(0)?.resource).toBe(preopen);
|
|
495
|
+
expect(descriptors.get(31)).toBeUndefined();
|
|
496
|
+
expect(releases).toBe(2);
|
|
497
|
+
} finally {
|
|
498
|
+
descriptors.dispose();
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
test("non-Error binding failures stay typed while cleanup failures remain on descriptor teardown", () => {
|
|
503
|
+
for (const primary of [null, undefined, 0, false]) {
|
|
504
|
+
const transport = createWorkerProcessTransport();
|
|
505
|
+
transport.bindings = [
|
|
506
|
+
{ fd: 17, reference: 0, rightsBase: 1n, rightsInheriting: 0n },
|
|
507
|
+
{ fd: 31, reference: 1, rightsBase: 1n, rightsInheriting: 0n },
|
|
508
|
+
];
|
|
509
|
+
transport.resources = ["retained", "reject"];
|
|
510
|
+
const descriptors = new DescriptorTable();
|
|
511
|
+
const stream: Stream = {
|
|
512
|
+
kind: "terminal",
|
|
513
|
+
read: () => 0,
|
|
514
|
+
write: () => 0,
|
|
515
|
+
readiness: () => ({ readable: false, writable: true, hangup: false }),
|
|
516
|
+
};
|
|
517
|
+
let releases = 0;
|
|
518
|
+
const codec: WorkerDescriptorCodec = {
|
|
519
|
+
import(token) {
|
|
520
|
+
if (token === "reject") throw primary;
|
|
521
|
+
return new OpenDescription(stream, () => {
|
|
522
|
+
releases++;
|
|
523
|
+
throw new Error("release failed");
|
|
524
|
+
});
|
|
525
|
+
},
|
|
526
|
+
export() {
|
|
527
|
+
throw new Error("unexpected export");
|
|
528
|
+
},
|
|
529
|
+
discard() {},
|
|
530
|
+
};
|
|
531
|
+
let caught: unknown;
|
|
532
|
+
try {
|
|
533
|
+
installWorkerBindings(transport, descriptors, codec);
|
|
534
|
+
} catch (error) {
|
|
535
|
+
caught = error;
|
|
536
|
+
}
|
|
537
|
+
expect(caught).toBe(primary);
|
|
538
|
+
expect(descriptors.get(17)).toBeUndefined();
|
|
539
|
+
expect(releases).toBe(1);
|
|
540
|
+
expect(() => descriptors.dispose()).toThrow("release failed");
|
|
541
|
+
expect(() => descriptors.dispose()).not.toThrow();
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
function rejectedTransfer(transport: WorkerProcessTransport) {
|
|
546
|
+
transport.bindings = [
|
|
547
|
+
{ fd: 17, reference: 0, rightsBase: 1n, rightsInheriting: 0n },
|
|
548
|
+
{ fd: 31, reference: 1, rightsBase: 1n, rightsInheriting: 0n },
|
|
549
|
+
];
|
|
550
|
+
transport.resources = ["retained", "reject"];
|
|
551
|
+
const primary = new ProcessError(2, "binding rejected");
|
|
552
|
+
const releaseFailure = new Error("staged release failed");
|
|
553
|
+
const stats = { releases: 0, rejectedDiscards: 0 };
|
|
554
|
+
const release = () => {
|
|
555
|
+
if (stats.releases) return;
|
|
556
|
+
stats.releases++;
|
|
557
|
+
throw releaseFailure;
|
|
558
|
+
};
|
|
559
|
+
const stream: Stream = {
|
|
560
|
+
kind: "terminal",
|
|
561
|
+
read: () => 0,
|
|
562
|
+
write: () => 0,
|
|
563
|
+
readiness: () => ({ readable: false, writable: true, hangup: false }),
|
|
564
|
+
};
|
|
565
|
+
const codec: WorkerDescriptorCodec = {
|
|
566
|
+
import(token) {
|
|
567
|
+
if (token === "reject") throw primary;
|
|
568
|
+
return new OpenDescription(stream, release);
|
|
569
|
+
},
|
|
570
|
+
export() {
|
|
571
|
+
throw new Error("unexpected export");
|
|
572
|
+
},
|
|
573
|
+
discard(token) {
|
|
574
|
+
if (token === "retained") release();
|
|
575
|
+
else stats.rejectedDiscards++;
|
|
576
|
+
},
|
|
577
|
+
};
|
|
578
|
+
return { primary, releaseFailure, stats, codec };
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
test("supervisor failStart reports staged cleanup once and reaches its fence without retrying disposal", async () => {
|
|
582
|
+
const transport = createWorkerProcessTransport(),
|
|
583
|
+
descriptors = new DescriptorTable();
|
|
584
|
+
const failure = rejectedTransfer(transport),
|
|
585
|
+
diagnostics: unknown[] = [];
|
|
586
|
+
let finishFence!: () => void;
|
|
587
|
+
const fence = new Promise<void>((resolve) => {
|
|
588
|
+
finishFence = resolve;
|
|
589
|
+
});
|
|
590
|
+
let fences = 0;
|
|
591
|
+
const supervisor = new ProcessSupervisor({
|
|
592
|
+
registry: new ExecutableRegistry(),
|
|
593
|
+
launch() {
|
|
594
|
+
throw new Error("must not launch");
|
|
595
|
+
},
|
|
596
|
+
onError(error) {
|
|
597
|
+
diagnostics.push(error);
|
|
598
|
+
},
|
|
599
|
+
quiesce() {
|
|
600
|
+
fences++;
|
|
601
|
+
return fence;
|
|
602
|
+
},
|
|
603
|
+
});
|
|
604
|
+
const pid = supervisor.createRoot({ descriptors });
|
|
605
|
+
try {
|
|
606
|
+
expect(() => installWorkerBindings(transport, descriptors, failure.codec)).toThrow(
|
|
607
|
+
failure.primary,
|
|
608
|
+
);
|
|
609
|
+
supervisor.failStart(pid, failure.primary);
|
|
610
|
+
expect(fences).toBe(1);
|
|
611
|
+
expect(supervisor.get(pid)!.result).toBeNull();
|
|
612
|
+
expect(diagnostics).toHaveLength(1);
|
|
613
|
+
expect((diagnostics[0] as AggregateError).errors[0].errors).toEqual([failure.releaseFailure]);
|
|
614
|
+
expect(() => descriptors.dispose()).not.toThrow();
|
|
615
|
+
supervisor.failStart(pid, failure.primary);
|
|
616
|
+
finishFence();
|
|
617
|
+
await fence;
|
|
618
|
+
expect(supervisor.get(pid)!.result).toEqual({
|
|
619
|
+
kind: "start-failed",
|
|
620
|
+
error: "EACCES",
|
|
621
|
+
code: 13,
|
|
622
|
+
status: null,
|
|
623
|
+
});
|
|
624
|
+
expect(failure.stats.releases).toBe(1);
|
|
625
|
+
expect(diagnostics).toHaveLength(1);
|
|
626
|
+
} finally {
|
|
627
|
+
finishFence();
|
|
628
|
+
await fence;
|
|
629
|
+
supervisor.dispose();
|
|
630
|
+
}
|
|
631
|
+
expect(diagnostics).toHaveLength(1);
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
test("broker import and staged release failures finish admission with typed outcome and one cleanup report", async () => {
|
|
635
|
+
const transport = createWorkerProcessTransport(),
|
|
636
|
+
descriptors = new DescriptorTable();
|
|
637
|
+
const state = workerProcessState(transport),
|
|
638
|
+
diagnostics: unknown[] = [];
|
|
639
|
+
let launches = 0,
|
|
640
|
+
fences = 0;
|
|
641
|
+
const supervisor = new ProcessSupervisor({
|
|
642
|
+
registry: new ExecutableRegistry(),
|
|
643
|
+
launch() {
|
|
644
|
+
launches++;
|
|
645
|
+
return { terminate() {} };
|
|
646
|
+
},
|
|
647
|
+
onError(error) {
|
|
648
|
+
diagnostics.push(error);
|
|
649
|
+
},
|
|
650
|
+
quiesce() {
|
|
651
|
+
fences++;
|
|
652
|
+
},
|
|
653
|
+
});
|
|
654
|
+
supervisor.createRoot({
|
|
655
|
+
pid: state.pid,
|
|
656
|
+
job: state.job,
|
|
657
|
+
observation: transport,
|
|
658
|
+
...state.signals,
|
|
659
|
+
});
|
|
660
|
+
const messages: WorkerProcessMessage[] = [];
|
|
661
|
+
const client = new WorkerProcessClient({
|
|
662
|
+
transport,
|
|
663
|
+
descriptors,
|
|
664
|
+
codec: fakeCodec().codec,
|
|
665
|
+
postMessage(message) {
|
|
666
|
+
messages.push(message);
|
|
667
|
+
},
|
|
668
|
+
});
|
|
669
|
+
const pid = client.spawn(state.pid, request()),
|
|
670
|
+
message = messages[0]!;
|
|
671
|
+
const failure = rejectedTransfer(message.transport);
|
|
672
|
+
const broker = new WorkerProcessBroker({
|
|
673
|
+
supervisor: () => Promise.resolve(supervisor),
|
|
674
|
+
codec: failure.codec,
|
|
675
|
+
});
|
|
676
|
+
broker.adoptRoot(transport);
|
|
677
|
+
try {
|
|
678
|
+
await expect(broker.handle(message)).rejects.toBe(failure.primary);
|
|
679
|
+
expect(launches).toBe(0);
|
|
680
|
+
expect(fences).toBe(1);
|
|
681
|
+
expect(diagnostics).toHaveLength(1);
|
|
682
|
+
expect((diagnostics[0] as AggregateError).errors[0].errors).toEqual([failure.releaseFailure]);
|
|
683
|
+
expect(failure.stats).toEqual({ releases: 1, rejectedDiscards: 1 });
|
|
684
|
+
expect(client.wait(state.pid, pid)).toEqual({
|
|
685
|
+
kind: "start-failed",
|
|
686
|
+
error: "EACCES",
|
|
687
|
+
code: 13,
|
|
688
|
+
status: null,
|
|
689
|
+
});
|
|
690
|
+
} finally {
|
|
691
|
+
broker.dispose();
|
|
692
|
+
supervisor.dispose();
|
|
693
|
+
descriptors.dispose();
|
|
694
|
+
}
|
|
695
|
+
expect(diagnostics).toHaveLength(1);
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
test("fatal selection freezes resources synchronously but wait stays pending until broker revocation completes", async () => {
|
|
699
|
+
const f = fixture();
|
|
700
|
+
const { fd } = f.source(f.root.options.descriptors);
|
|
701
|
+
const pid = f.root.spawn(1, request({ fds: [{ child: 1, parent: fd }] }));
|
|
702
|
+
await f.flush();
|
|
703
|
+
await f.supervisor.start(pid);
|
|
704
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
705
|
+
const before = controlLoad(f.root.wake, 0);
|
|
706
|
+
f.root.kill(pid, 9);
|
|
707
|
+
expect(f.revoked).toEqual([pid]);
|
|
708
|
+
expect(readOutcome(state.signals.outcome)?.status).toBe(137);
|
|
709
|
+
expect(f.root.wait(1, pid)).toBeNull();
|
|
710
|
+
expect(controlLoad(f.root.wake, 0)).toBeGreaterThan(before);
|
|
711
|
+
await f.flush();
|
|
712
|
+
expect(controlLoad(state.confirmed, 0)).toBe(1);
|
|
713
|
+
expect(f.root.wait(1, pid)).toEqual({ kind: "signaled", code: 9, status: 137 });
|
|
714
|
+
expectErrno(() => controlLoad(state.confirmed), 71);
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
test("handled and ignored signals preserve resource authority and share the disposition state", async () => {
|
|
718
|
+
const f = fixture();
|
|
719
|
+
const pid = f.root.spawn(1, request());
|
|
720
|
+
await f.flush();
|
|
721
|
+
await f.supervisor.start(pid);
|
|
722
|
+
const child = f.client(f.broker.get(pid)!);
|
|
723
|
+
setSignalDisposition(child.signals.signalState, 15, SignalDisposition.HANDLE);
|
|
724
|
+
f.root.kill(pid, 15);
|
|
725
|
+
expect(f.revoked).toEqual([]);
|
|
726
|
+
expect(controlLoad(child.signals.signalState, 15)).toBe(SignalDisposition.HANDLE | 4);
|
|
727
|
+
setSignalDisposition(child.signals.signalState, 2, SignalDisposition.IGNORE);
|
|
728
|
+
f.root.kill(pid, 2);
|
|
729
|
+
expect(f.revoked).toEqual([]);
|
|
730
|
+
await f.flush();
|
|
731
|
+
expect(f.root.wait(1, pid)).toBeNull();
|
|
732
|
+
child.exit(23);
|
|
733
|
+
await f.flush();
|
|
734
|
+
expect(f.root.wait(1, pid)?.code).toBe(23);
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
test("a kill before lazy activation prevents launch and releases all inherited endpoint refs", async () => {
|
|
738
|
+
const f = fixture();
|
|
739
|
+
const { fd, counts } = f.source(f.root.options.descriptors);
|
|
740
|
+
const pid = f.root.spawn(1, request({ fds: [{ child: 8, parent: fd }] }));
|
|
741
|
+
f.root.options.descriptors.close(fd);
|
|
742
|
+
f.root.kill(pid, 9);
|
|
743
|
+
expect(f.root.wait(1, pid)).toBeNull();
|
|
744
|
+
await f.flush();
|
|
745
|
+
await f.supervisor.start(pid);
|
|
746
|
+
expect(f.contexts.has(pid)).toBe(false);
|
|
747
|
+
expect(f.root.wait(1, pid)?.status).toBe(137);
|
|
748
|
+
expect(counts[0]).toBe(0);
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
test("worker authority permits self and descendants but not sibling processes or unowned jobs", async () => {
|
|
752
|
+
const f = fixture();
|
|
753
|
+
const a = f.root.spawn(1, request()),
|
|
754
|
+
b = f.root.spawn(1, request());
|
|
755
|
+
await f.flush();
|
|
756
|
+
const child = f.client(f.broker.get(a)!);
|
|
757
|
+
expect(() => child.kill(b, 9)).toThrow("ancestry");
|
|
758
|
+
expect(() => child.killJob(f.root.jobOf(b), 9)).toThrow("not owned");
|
|
759
|
+
const grandchild = child.spawn(a, request({ job: child.job }));
|
|
760
|
+
await f.flush();
|
|
761
|
+
expect(child.canSignal(a, grandchild)).toBe(true);
|
|
762
|
+
expect(f.root.canSignal(1, grandchild)).toBe(true);
|
|
763
|
+
f.root.killJob(child.job, 9);
|
|
764
|
+
expect(f.revoked).toEqual([a, grandchild]);
|
|
765
|
+
await f.flush();
|
|
766
|
+
expect(f.root.wait(1, a)?.status).toBe(137);
|
|
767
|
+
expect(f.root.wait(1, b)).toBeNull();
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
test("uncollected zombies retain bounded capacity and keep unique process identities", async () => {
|
|
771
|
+
const f = fixture({ capacity: 2 });
|
|
772
|
+
const pid = f.root.spawn(1, request());
|
|
773
|
+
await f.flush();
|
|
774
|
+
await f.supervisor.start(pid);
|
|
775
|
+
f.contexts.get(pid)!.exit(0);
|
|
776
|
+
expect(f.root.childExited(1, pid)).toBe(true);
|
|
777
|
+
expect(() => f.root.spawn(1, request())).toThrow("directory is full");
|
|
778
|
+
expect(f.messages.length).toBe(0);
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
test("failed transfer unwinds retained lifetimes and the source admission transaction", () => {
|
|
782
|
+
const f = fixture();
|
|
783
|
+
const one = f.source(f.root.options.descriptors),
|
|
784
|
+
two = f.source(f.root.options.descriptors);
|
|
785
|
+
let exports = 0,
|
|
786
|
+
cancelled = 0;
|
|
787
|
+
const codec: WorkerDescriptorCodec = {
|
|
788
|
+
...f.codec,
|
|
789
|
+
export(source, pid) {
|
|
790
|
+
if (++exports === 2) throw new Error("reservation failed");
|
|
791
|
+
return f.codec.export(source, pid);
|
|
792
|
+
},
|
|
793
|
+
};
|
|
794
|
+
const client = new WorkerProcessClient({
|
|
795
|
+
...f.root.options,
|
|
796
|
+
prepareSpawn: () => ({
|
|
797
|
+
codec,
|
|
798
|
+
cancel() {
|
|
799
|
+
cancelled++;
|
|
800
|
+
},
|
|
801
|
+
}),
|
|
802
|
+
});
|
|
803
|
+
expect(() =>
|
|
804
|
+
client.spawn(
|
|
805
|
+
1,
|
|
806
|
+
request({
|
|
807
|
+
fds: [
|
|
808
|
+
{ child: 1, parent: one.fd },
|
|
809
|
+
{ child: 2, parent: two.fd },
|
|
810
|
+
],
|
|
811
|
+
}),
|
|
812
|
+
),
|
|
813
|
+
).toThrow("reservation failed");
|
|
814
|
+
expect(cancelled).toBe(1);
|
|
815
|
+
expect(one.counts[0]).toBe(1);
|
|
816
|
+
expect(two.counts[0]).toBe(1);
|
|
817
|
+
expect(f.messages.length).toBe(0);
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
test("transfer transaction commits only after publishing its independently-owned context", () => {
|
|
821
|
+
const f = fixture();
|
|
822
|
+
const order: string[] = [];
|
|
823
|
+
const client = new WorkerProcessClient({
|
|
824
|
+
...f.root.options,
|
|
825
|
+
prepareSpawn: () => ({
|
|
826
|
+
data: { filesystem: "child" },
|
|
827
|
+
commit() {
|
|
828
|
+
order.push("commit");
|
|
829
|
+
},
|
|
830
|
+
cancel() {
|
|
831
|
+
order.push("cancel");
|
|
832
|
+
},
|
|
833
|
+
}),
|
|
834
|
+
postMessage(message) {
|
|
835
|
+
order.push("publish");
|
|
836
|
+
f.messages.push(structuredClone(message));
|
|
837
|
+
},
|
|
838
|
+
});
|
|
839
|
+
client.spawn(1, request());
|
|
840
|
+
expect(order).toEqual(["publish", "commit"]);
|
|
841
|
+
expect(f.messages[0]!.transport.data).toEqual({ filesystem: "child" });
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
test("lazy activation failure releases transferred lifetimes before confirming EIO", async () => {
|
|
845
|
+
const f = fixture({
|
|
846
|
+
activate: async () => {
|
|
847
|
+
throw new Error("chunk failed");
|
|
848
|
+
},
|
|
849
|
+
});
|
|
850
|
+
const { fd, counts } = f.source(f.root.options.descriptors);
|
|
851
|
+
const pid = f.root.spawn(1, request({ fds: [{ child: 17, parent: fd }] }));
|
|
852
|
+
f.root.options.descriptors.close(fd);
|
|
853
|
+
await expect(f.flush()).rejects.toThrow("chunk failed");
|
|
854
|
+
expect(counts[0]).toBe(0);
|
|
855
|
+
expect(f.root.wait(1, pid)).toEqual({
|
|
856
|
+
kind: "start-failed",
|
|
857
|
+
code: 5,
|
|
858
|
+
error: "EIO",
|
|
859
|
+
status: null,
|
|
860
|
+
});
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
test("an admitted independent child survives its parent's exit before lazy activation", async () => {
|
|
864
|
+
const f = fixture();
|
|
865
|
+
const { fd, counts } = f.source(f.root.options.descriptors, "directory");
|
|
866
|
+
const pid = f.root.spawn(1, request({ job: -1, fds: [{ child: 11, parent: fd }] }));
|
|
867
|
+
f.root.options.descriptors.close(fd);
|
|
868
|
+
f.supervisor.exit(1, 0);
|
|
869
|
+
await f.flush();
|
|
870
|
+
await f.supervisor.start(pid);
|
|
871
|
+
expect(f.contexts.has(pid)).toBe(true);
|
|
872
|
+
expect(counts[0]).toBe(1);
|
|
873
|
+
f.contexts.get(pid)!.exit(0);
|
|
874
|
+
expect(counts[0]).toBe(0);
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
test("repeated spawn messages cannot close or replace the first accepted process", async () => {
|
|
878
|
+
const f = fixture();
|
|
879
|
+
const { fd, counts } = f.source(f.root.options.descriptors);
|
|
880
|
+
const pid = f.root.spawn(1, request({ fds: [{ child: 1, parent: fd }] }));
|
|
881
|
+
const duplicate = structuredClone(f.messages[0]!);
|
|
882
|
+
f.root.options.descriptors.close(fd);
|
|
883
|
+
await f.flush();
|
|
884
|
+
await f.supervisor.start(pid);
|
|
885
|
+
await expect(f.broker.handle(duplicate)).rejects.toThrow("already registered");
|
|
886
|
+
expect(f.broker.get(pid)).toBeDefined();
|
|
887
|
+
expect(counts[0]).toBe(1);
|
|
888
|
+
});
|
|
889
|
+
|
|
890
|
+
test("an ordinary exit with a signal-shaped code remains ordinary after a late kill", async () => {
|
|
891
|
+
const f = fixture();
|
|
892
|
+
const pid = f.root.spawn(1, request());
|
|
893
|
+
await f.flush();
|
|
894
|
+
await f.supervisor.start(pid);
|
|
895
|
+
const child = f.client(f.broker.get(pid)!);
|
|
896
|
+
child.exit(143);
|
|
897
|
+
await f.flush();
|
|
898
|
+
f.root.kill(pid, 9);
|
|
899
|
+
await f.flush();
|
|
900
|
+
expect(f.revoked).toEqual([]);
|
|
901
|
+
expect(f.root.wait(1, pid)).toEqual({ kind: "exited", code: 143, status: 143 });
|
|
902
|
+
});
|
|
903
|
+
|
|
904
|
+
test("worker job wait requires confirmed descendants and retains the directly-reaped leader outcome", async () => {
|
|
905
|
+
const f = fixture();
|
|
906
|
+
const leaderPid = f.root.spawn(1, request());
|
|
907
|
+
await f.flush();
|
|
908
|
+
const leader = f.client(f.broker.get(leaderPid)!);
|
|
909
|
+
const descendantPid = leader.spawn(leaderPid, request({ job: leader.job }));
|
|
910
|
+
await f.flush();
|
|
911
|
+
const descendant = f.client(f.broker.get(descendantPid)!);
|
|
912
|
+
leader.exit(23);
|
|
913
|
+
expect(f.root.jobEmpty(1, leader.job)).toBe(false);
|
|
914
|
+
expect(f.root.waitJob(1, leader.job)).toBeNull();
|
|
915
|
+
await f.flush();
|
|
916
|
+
expect(f.supervisor.reap(1, leaderPid)?.code).toBe(23);
|
|
917
|
+
expect(f.root.jobEmpty(1, leader.job)).toBe(false);
|
|
918
|
+
descendant.exit(7);
|
|
919
|
+
expect(f.root.waitJob(1, leader.job)).toBeNull();
|
|
920
|
+
await f.flush();
|
|
921
|
+
expect(f.root.jobEmpty(1, leader.job)).toBe(true);
|
|
922
|
+
expect(f.root.jobEmpty(1, leader.job)).toBe(true);
|
|
923
|
+
expect(f.root.waitJob(1, leader.job)).toEqual({ kind: "exited", code: 23, status: 23 });
|
|
924
|
+
expectErrno(() => f.root.waitJob(1, leader.job), 12);
|
|
925
|
+
expectErrno(() => f.root.jobEmpty(1, leader.job), 12);
|
|
926
|
+
expectErrno(() => f.root.wait(1, leaderPid), 12);
|
|
927
|
+
expectErrno(() => f.root.jobOf(descendantPid), 71);
|
|
928
|
+
expectErrno(() => f.root.kill(leaderPid, 9), 71);
|
|
929
|
+
await f.flush();
|
|
930
|
+
expect(f.supervisor.get(descendantPid)).toBeUndefined();
|
|
931
|
+
expect(f.broker.get(leaderPid)).toBeUndefined();
|
|
932
|
+
expect(f.broker.get(descendantPid)).toBeUndefined();
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
test("pump skips a shared job collected after listing and before its lifetime load", async () => {
|
|
936
|
+
const f = fixture();
|
|
937
|
+
const pid = f.root.spawn(1, request());
|
|
938
|
+
await f.flush();
|
|
939
|
+
const child = f.client(f.broker.get(pid)!);
|
|
940
|
+
child.exit(0);
|
|
941
|
+
await f.flush();
|
|
942
|
+
expect(f.root.jobEmpty(1, child.job)).toBe(true);
|
|
943
|
+
expect(f.supervisor.job(child.job)).toBeDefined();
|
|
944
|
+
// Another worker's wait consumes the job after pump() listed it but before pump()
|
|
945
|
+
// reads its lifetime word. pump() looks up the host job record in between.
|
|
946
|
+
const lookup = f.supervisor.job.bind(f.supervisor);
|
|
947
|
+
let collected: ReturnType<typeof f.root.waitJob> | undefined;
|
|
948
|
+
f.supervisor.job = (id: number) => {
|
|
949
|
+
if (id === child.job && collected === undefined) collected = f.root.waitJob(1, child.job);
|
|
950
|
+
return lookup(id);
|
|
951
|
+
};
|
|
952
|
+
expect(() => f.broker.pump()).not.toThrow();
|
|
953
|
+
f.supervisor.job = lookup;
|
|
954
|
+
expect(collected?.status).toBe(0);
|
|
955
|
+
expect(findDirectoryJob(f.transport.directory, child.job)).toBeUndefined();
|
|
956
|
+
// The consumed job still retires on the host; nothing it owned is dropped early.
|
|
957
|
+
await f.flush();
|
|
958
|
+
f.broker.pump();
|
|
959
|
+
expect(f.supervisor.job(child.job)).toBeUndefined();
|
|
960
|
+
expect(f.supervisor.get(pid)).toBeUndefined();
|
|
961
|
+
expect(f.broker.get(pid)).toBeUndefined();
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
test("worker process and job completion both await the host-work fence", async () => {
|
|
965
|
+
let finish!: () => void;
|
|
966
|
+
const fence = new Promise<void>((resolve) => {
|
|
967
|
+
finish = resolve;
|
|
968
|
+
});
|
|
969
|
+
const f = fixture({ quiesce: () => fence });
|
|
970
|
+
const pid = f.root.spawn(1, request());
|
|
971
|
+
await f.flush();
|
|
972
|
+
const child = f.client(f.broker.get(pid)!);
|
|
973
|
+
child.exit(0);
|
|
974
|
+
await f.flush();
|
|
975
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
976
|
+
expect(f.root.wait(1, pid)).toBeNull();
|
|
977
|
+
expect(controlLoad(state.confirmed, 0)).toBe(0);
|
|
978
|
+
expect(controlLoad(state.jobConfirmed, 0)).toBe(0);
|
|
979
|
+
expect(f.root.waitJob(1, child.job)).toBeNull();
|
|
980
|
+
const before = controlLoad(f.root.wake, 0);
|
|
981
|
+
finish();
|
|
982
|
+
await fence;
|
|
983
|
+
await Promise.resolve();
|
|
984
|
+
expect(controlLoad(f.root.wake, 0)).toBeGreaterThan(before);
|
|
985
|
+
expect(controlLoad(state.confirmed, 0)).toBe(1);
|
|
986
|
+
expect(f.root.wait(1, pid)?.status).toBe(0);
|
|
987
|
+
expectErrno(() => controlLoad(state.confirmed), 71);
|
|
988
|
+
expect(f.root.jobEmpty(1, child.job)).toBe(true);
|
|
989
|
+
expect(f.root.waitJob(1, child.job)?.status).toBe(0);
|
|
990
|
+
await f.flush();
|
|
991
|
+
});
|
|
992
|
+
|
|
993
|
+
test("rejected worker admissions fence host work before publishing safe job completion", async () => {
|
|
994
|
+
let finish!: () => void, began!: () => void;
|
|
995
|
+
const fence = new Promise<void>((resolve) => {
|
|
996
|
+
finish = resolve;
|
|
997
|
+
});
|
|
998
|
+
const started = new Promise<void>((resolve) => {
|
|
999
|
+
began = resolve;
|
|
1000
|
+
});
|
|
1001
|
+
const f = fixture({
|
|
1002
|
+
activate: async () => {
|
|
1003
|
+
throw new Error("chunk failed");
|
|
1004
|
+
},
|
|
1005
|
+
rejectedQuiesce: () => {
|
|
1006
|
+
began();
|
|
1007
|
+
return fence;
|
|
1008
|
+
},
|
|
1009
|
+
});
|
|
1010
|
+
const pid = f.root.spawn(1, request());
|
|
1011
|
+
const pending = f.flush();
|
|
1012
|
+
await started;
|
|
1013
|
+
expect(f.root.wait(1, pid)).toBeNull();
|
|
1014
|
+
const job = f.root.jobOf(pid);
|
|
1015
|
+
expect(f.root.jobEmpty(1, job)).toBe(false);
|
|
1016
|
+
finish();
|
|
1017
|
+
await expect(pending).rejects.toThrow("chunk failed");
|
|
1018
|
+
expect(f.root.wait(1, pid)).toMatchObject({ kind: "start-failed", error: "EIO", status: null });
|
|
1019
|
+
expect(f.root.jobEmpty(1, job)).toBe(true);
|
|
1020
|
+
});
|
|
1021
|
+
|
|
1022
|
+
test("worker job wait has retained owner ancestry and rejects siblings and unknown jobs", async () => {
|
|
1023
|
+
const f = fixture();
|
|
1024
|
+
const ownerPid = f.root.spawn(1, request()),
|
|
1025
|
+
siblingPid = f.root.spawn(1, request());
|
|
1026
|
+
await f.flush();
|
|
1027
|
+
const owner = f.client(f.broker.get(ownerPid)!),
|
|
1028
|
+
sibling = f.client(f.broker.get(siblingPid)!);
|
|
1029
|
+
const memberPid = owner.spawn(ownerPid, request());
|
|
1030
|
+
await f.flush();
|
|
1031
|
+
const member = f.client(f.broker.get(memberPid)!);
|
|
1032
|
+
owner.exit(0);
|
|
1033
|
+
await f.flush();
|
|
1034
|
+
expect(f.root.waitJob(1, owner.job)?.status).toBe(0);
|
|
1035
|
+
await f.flush();
|
|
1036
|
+
expectErrno(() => f.root.jobOf(ownerPid), 71);
|
|
1037
|
+
expect(f.root.canSignal(1, memberPid)).toBe(true);
|
|
1038
|
+
expect(f.root.jobEmpty(1, member.job)).toBe(false);
|
|
1039
|
+
expectErrno(() => sibling.waitJob(siblingPid, member.job), 63);
|
|
1040
|
+
expectErrno(() => f.root.waitJob(siblingPid, member.job), 63);
|
|
1041
|
+
expectErrno(() => f.root.waitJob(1, 999999), 71);
|
|
1042
|
+
member.exit(0);
|
|
1043
|
+
await f.flush();
|
|
1044
|
+
expect(f.root.waitJob(1, member.job)?.status).toBe(0);
|
|
1045
|
+
await f.flush();
|
|
1046
|
+
expect(f.supervisor.get(memberPid)).toBeUndefined();
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1049
|
+
test("queued worker reap notices retain authority after their caller is itself reaped", async () => {
|
|
1050
|
+
const f = fixture();
|
|
1051
|
+
const ownerPid = f.root.spawn(1, request());
|
|
1052
|
+
await f.flush();
|
|
1053
|
+
const owner = f.client(f.broker.get(ownerPid)!);
|
|
1054
|
+
const childPid = owner.spawn(ownerPid, request());
|
|
1055
|
+
await f.flush();
|
|
1056
|
+
const child = f.client(f.broker.get(childPid)!);
|
|
1057
|
+
child.exit(8);
|
|
1058
|
+
await f.flush();
|
|
1059
|
+
expect(owner.waitJob(ownerPid, child.job)?.status).toBe(8);
|
|
1060
|
+
const delayed = f.messages.shift()!;
|
|
1061
|
+
owner.exit(0);
|
|
1062
|
+
await f.flush();
|
|
1063
|
+
expect(f.root.waitJob(1, owner.job)?.status).toBe(0);
|
|
1064
|
+
await f.flush();
|
|
1065
|
+
expect(f.supervisor.get(ownerPid)).toBeUndefined();
|
|
1066
|
+
expect(f.supervisor.get(childPid)).toBeUndefined();
|
|
1067
|
+
await f.broker.handle(delayed, ownerPid);
|
|
1068
|
+
expect(f.supervisor.get(childPid)).toBeUndefined();
|
|
1069
|
+
expect(f.broker.get(childPid)).toBeUndefined();
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
test("reaping one job keeps another directly reaped process collectable by its own notice", async () => {
|
|
1073
|
+
const f = fixture();
|
|
1074
|
+
const reapedPid = f.root.spawn(1, request()),
|
|
1075
|
+
claimedPid = f.root.spawn(1, request());
|
|
1076
|
+
await f.flush();
|
|
1077
|
+
const reaped = f.client(f.broker.get(reapedPid)!),
|
|
1078
|
+
claimed = f.client(f.broker.get(claimedPid)!);
|
|
1079
|
+
reaped.exit(0);
|
|
1080
|
+
claimed.exit(0);
|
|
1081
|
+
await f.flush();
|
|
1082
|
+
// The process notice is handled while the other job's guest claim is still unacknowledged.
|
|
1083
|
+
expect(f.root.wait(1, reapedPid)?.status).toBe(0);
|
|
1084
|
+
expect(f.root.waitJob(1, claimed.job)?.status).toBe(0);
|
|
1085
|
+
await f.flush();
|
|
1086
|
+
expect(f.supervisor.get(reapedPid)).toBeUndefined();
|
|
1087
|
+
expect(f.supervisor.get(claimedPid)).toBeUndefined();
|
|
1088
|
+
expect(f.broker.get(reapedPid)).toBeUndefined();
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
test("accepted separate-job spawns keep their descriptors after the parent job is reaped", async () => {
|
|
1092
|
+
const f = fixture();
|
|
1093
|
+
const ownerPid = f.root.spawn(1, request());
|
|
1094
|
+
await f.flush();
|
|
1095
|
+
const owner = f.client(f.broker.get(ownerPid)!);
|
|
1096
|
+
const { fd, counts } = f.source(owner.options.descriptors, "directory");
|
|
1097
|
+
const childPid = owner.spawn(ownerPid, request({ job: -1, fds: [{ child: 19, parent: fd }] }));
|
|
1098
|
+
owner.options.descriptors.close(fd);
|
|
1099
|
+
const delayed = f.messages.shift()!;
|
|
1100
|
+
owner.exit(0);
|
|
1101
|
+
await f.flush();
|
|
1102
|
+
expect(f.root.waitJob(1, owner.job)?.status).toBe(0);
|
|
1103
|
+
await f.flush();
|
|
1104
|
+
expect(f.broker.get(ownerPid)).toBeUndefined();
|
|
1105
|
+
expect(f.broker.getIdentity(ownerPid)).toBeUndefined();
|
|
1106
|
+
await f.broker.handle(delayed, ownerPid);
|
|
1107
|
+
await f.supervisor.start(childPid);
|
|
1108
|
+
expect(f.contexts.get(childPid)!.descriptors.get(19)!.resource.kind).toBe("directory");
|
|
1109
|
+
expect(counts[0]).toBe(1);
|
|
1110
|
+
const child = f.client(f.broker.get(childPid)!);
|
|
1111
|
+
child.exit(0);
|
|
1112
|
+
await f.flush();
|
|
1113
|
+
expect(f.root.waitJob(1, child.job)?.status).toBe(0);
|
|
1114
|
+
await f.flush();
|
|
1115
|
+
expect(counts[0]).toBe(0);
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
test("worker job membership cannot reopen safely completed or reaped jobs", async () => {
|
|
1119
|
+
const f = fixture();
|
|
1120
|
+
const pid = f.root.spawn(1, request());
|
|
1121
|
+
await f.flush();
|
|
1122
|
+
const child = f.client(f.broker.get(pid)!);
|
|
1123
|
+
child.exit(0);
|
|
1124
|
+
// Selected outcomes alone do not seal a job: cleanup is still pending.
|
|
1125
|
+
const joined = f.root.spawn(1, request({ job: child.job }));
|
|
1126
|
+
await f.broker.handle(f.messages.shift()!);
|
|
1127
|
+
// The host has not received the accepted join yet; its shared-directory guard
|
|
1128
|
+
// must prevent a direct host waiter from reaping the incomplete job.
|
|
1129
|
+
expect(f.supervisor.waitJob(1, child.job)).toBeNull();
|
|
1130
|
+
await f.flush();
|
|
1131
|
+
const member = f.client(f.broker.get(joined)!);
|
|
1132
|
+
expect(f.root.jobEmpty(1, child.job)).toBe(false);
|
|
1133
|
+
member.exit(0);
|
|
1134
|
+
await f.flush();
|
|
1135
|
+
expectErrno(() => f.root.spawn(1, request({ job: child.job })), 12);
|
|
1136
|
+
expect(f.root.waitJob(1, child.job)?.status).toBe(0);
|
|
1137
|
+
expectErrno(() => f.root.spawn(1, request({ job: child.job })), 12);
|
|
1138
|
+
await f.flush();
|
|
1139
|
+
});
|
|
1140
|
+
|
|
1141
|
+
test("worker transfer fences precede membership reservation and cancel on directory exhaustion", () => {
|
|
1142
|
+
const f = fixture({ capacity: 1 });
|
|
1143
|
+
let prepared = 0,
|
|
1144
|
+
cancelled = 0;
|
|
1145
|
+
const client = new WorkerProcessClient({
|
|
1146
|
+
...f.root.options,
|
|
1147
|
+
prepareSpawn() {
|
|
1148
|
+
expect(directorySlots(f.transport.directory)).toHaveLength(1);
|
|
1149
|
+
prepared++;
|
|
1150
|
+
return {
|
|
1151
|
+
cancel() {
|
|
1152
|
+
cancelled++;
|
|
1153
|
+
},
|
|
1154
|
+
};
|
|
1155
|
+
},
|
|
1156
|
+
});
|
|
1157
|
+
expectErrno(() => client.spawn(1, request({ job: f.root.job })), 6);
|
|
1158
|
+
expect(prepared).toBe(1);
|
|
1159
|
+
expect(cancelled).toBe(1);
|
|
1160
|
+
expect(controlLoad(workerProcessState(f.transport).jobPending, 0)).toBe(1);
|
|
1161
|
+
});
|
|
1162
|
+
|
|
1163
|
+
test("failed leader imports retain host leader identity and outcome for queued job members", async () => {
|
|
1164
|
+
const f = fixture();
|
|
1165
|
+
const { fd } = f.source(f.root.options.descriptors, "directory");
|
|
1166
|
+
const leaderPid = f.root.spawn(1, request({ fds: [{ child: 19, parent: fd }] }));
|
|
1167
|
+
const job = f.root.jobOf(leaderPid);
|
|
1168
|
+
const joinedPid = f.root.spawn(1, request({ job }));
|
|
1169
|
+
const original = f.codec.import;
|
|
1170
|
+
let imports = 0;
|
|
1171
|
+
f.codec.import = (token, pid) => {
|
|
1172
|
+
if (++imports === 1) throw new Error("import failed");
|
|
1173
|
+
return original(token, pid);
|
|
1174
|
+
};
|
|
1175
|
+
await expect(f.flush()).rejects.toThrow("import failed");
|
|
1176
|
+
expect(f.supervisor.get(leaderPid)?.result).toMatchObject({
|
|
1177
|
+
kind: "start-failed",
|
|
1178
|
+
error: "EIO",
|
|
1179
|
+
status: null,
|
|
1180
|
+
});
|
|
1181
|
+
expect(f.root.jobEmpty(1, job)).toBe(false);
|
|
1182
|
+
await f.flush();
|
|
1183
|
+
const joined = f.client(f.broker.get(joinedPid)!);
|
|
1184
|
+
joined.exit(7);
|
|
1185
|
+
await f.flush();
|
|
1186
|
+
expect(f.root.waitJob(1, job)).toMatchObject({
|
|
1187
|
+
kind: "start-failed",
|
|
1188
|
+
error: "EIO",
|
|
1189
|
+
status: null,
|
|
1190
|
+
});
|
|
1191
|
+
await f.flush();
|
|
1192
|
+
expect(f.supervisor.get(joinedPid)).toBeUndefined();
|
|
1193
|
+
});
|
|
1194
|
+
|
|
1195
|
+
test("guest job claims exclude host consumers until the broker acknowledges them", async () => {
|
|
1196
|
+
const f = fixture();
|
|
1197
|
+
const pid = f.root.spawn(1, request());
|
|
1198
|
+
await f.flush();
|
|
1199
|
+
const child = f.client(f.broker.get(pid)!);
|
|
1200
|
+
child.exit(8);
|
|
1201
|
+
await f.flush();
|
|
1202
|
+
expect(f.root.waitJob(1, child.job)?.status).toBe(8);
|
|
1203
|
+
expectErrno(() => f.supervisor.waitJob(1, child.job), 12);
|
|
1204
|
+
expectErrno(() => f.supervisor.jobEmpty(1, child.job), 12);
|
|
1205
|
+
expect(f.supervisor.get(pid)).toBeDefined();
|
|
1206
|
+
await f.flush();
|
|
1207
|
+
expect(f.supervisor.get(pid)).toBeUndefined();
|
|
1208
|
+
expectErrno(() => f.supervisor.waitJob(1, child.job), 12);
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
test("guest claims racing after host readiness win before host metadata is consumed", async () => {
|
|
1212
|
+
let race: (() => void) | undefined;
|
|
1213
|
+
const f = fixture({
|
|
1214
|
+
beforeActivation(supervisor) {
|
|
1215
|
+
supervisor.registerJobReapClaim(() => {
|
|
1216
|
+
const claim = race;
|
|
1217
|
+
race = undefined;
|
|
1218
|
+
claim?.();
|
|
1219
|
+
return true;
|
|
1220
|
+
});
|
|
1221
|
+
},
|
|
1222
|
+
});
|
|
1223
|
+
const pid = f.root.spawn(1, request());
|
|
1224
|
+
await f.flush();
|
|
1225
|
+
const child = f.client(f.broker.get(pid)!);
|
|
1226
|
+
child.exit(8);
|
|
1227
|
+
await f.flush();
|
|
1228
|
+
let status: number | null | undefined;
|
|
1229
|
+
race = () => {
|
|
1230
|
+
status = f.root.waitJob(1, child.job)?.status;
|
|
1231
|
+
};
|
|
1232
|
+
expectErrno(() => f.supervisor.waitJob(1, child.job), 12);
|
|
1233
|
+
expect(status).toBe(8);
|
|
1234
|
+
expect(f.supervisor.get(pid)).toBeDefined();
|
|
1235
|
+
await f.flush();
|
|
1236
|
+
expect(f.supervisor.get(pid)).toBeUndefined();
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
test("host job reap tombstones worker-visible processes synchronously", async () => {
|
|
1240
|
+
const f = fixture();
|
|
1241
|
+
const pid = f.root.spawn(1, request());
|
|
1242
|
+
await f.flush();
|
|
1243
|
+
const child = f.client(f.broker.get(pid)!);
|
|
1244
|
+
child.exit(0);
|
|
1245
|
+
await f.flush();
|
|
1246
|
+
f.supervisor.registerJobReapClaim(() => {
|
|
1247
|
+
// This hook runs after the broker claim but before host metadata deletion.
|
|
1248
|
+
expectErrno(() => f.root.waitJob(1, child.job), 12);
|
|
1249
|
+
return true;
|
|
1250
|
+
});
|
|
1251
|
+
expect(f.supervisor.waitJob(1, child.job)?.status).toBe(0);
|
|
1252
|
+
expectErrno(() => f.root.waitJob(1, child.job), 12);
|
|
1253
|
+
expectErrno(() => f.root.jobOf(pid), 71);
|
|
1254
|
+
expect(f.broker.get(pid)).toBeUndefined();
|
|
1255
|
+
expect(f.broker.getIdentity(pid)).toBeUndefined();
|
|
1256
|
+
});
|
|
1257
|
+
|
|
1258
|
+
test("failed synchronous worker transfers release inaccessible process and job reservations", async () => {
|
|
1259
|
+
const f = fixture();
|
|
1260
|
+
const { fd } = f.source(f.root.options.descriptors);
|
|
1261
|
+
const client = new WorkerProcessClient({
|
|
1262
|
+
...f.root.options,
|
|
1263
|
+
codec: {
|
|
1264
|
+
...f.codec,
|
|
1265
|
+
export() {
|
|
1266
|
+
throw new Error("transfer failed");
|
|
1267
|
+
},
|
|
1268
|
+
},
|
|
1269
|
+
});
|
|
1270
|
+
for (let cycle = 0; cycle < 12; cycle++) {
|
|
1271
|
+
expect(() => client.spawn(1, request({ fds: [{ child: 1, parent: fd }] }))).toThrow(
|
|
1272
|
+
"transfer failed",
|
|
1273
|
+
);
|
|
1274
|
+
expect(directorySlots(f.transport.directory)).toEqual([0]);
|
|
1275
|
+
expect(directoryJobs(f.transport.directory).length).toBe(1);
|
|
1276
|
+
expectErrno(() => f.root.wait(1, cycle + 2), 12);
|
|
1277
|
+
}
|
|
1278
|
+
expect(f.messages.length).toBe(0);
|
|
1279
|
+
await f.flush();
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1282
|
+
test("broker rejects a foreign sender without accepting its process reservation", async () => {
|
|
1283
|
+
const f = fixture();
|
|
1284
|
+
const pid = f.root.spawn(1, request());
|
|
1285
|
+
await expect(f.broker.handle(f.messages.shift()!, 999)).rejects.toThrow("wrong sender");
|
|
1286
|
+
expect(f.broker.get(pid)).toBeUndefined();
|
|
1287
|
+
});
|
|
1288
|
+
|
|
1289
|
+
test("shared job leader, owner and foreground survive reordered successful admissions", async () => {
|
|
1290
|
+
for (const selection of [0, -1]) {
|
|
1291
|
+
const f = fixture();
|
|
1292
|
+
const ownerPid = f.root.spawn(1, request({ job: -1 }));
|
|
1293
|
+
await f.flush();
|
|
1294
|
+
const owner = f.client(f.broker.get(ownerPid)!);
|
|
1295
|
+
const leaderPid = owner.spawn(ownerPid, request({ job: selection }));
|
|
1296
|
+
const job = owner.jobOf(leaderPid);
|
|
1297
|
+
const leaderMessage = f.messages.shift()!;
|
|
1298
|
+
const memberPid = f.root.spawn(1, request({ job }));
|
|
1299
|
+
await f.broker.handle(f.messages.shift()!);
|
|
1300
|
+
expect(f.supervisor.job(job)).toMatchObject({
|
|
1301
|
+
ownerPid,
|
|
1302
|
+
leaderPid,
|
|
1303
|
+
foreground: selection === 0,
|
|
1304
|
+
leaderResult: null,
|
|
1305
|
+
});
|
|
1306
|
+
expect(f.supervisor.canWaitJob(ownerPid, job)).toBe(true);
|
|
1307
|
+
const member = f.client(f.broker.get(memberPid)!);
|
|
1308
|
+
member.exit(19);
|
|
1309
|
+
await f.flush();
|
|
1310
|
+
expect(f.supervisor.waitJob(ownerPid, job)).toBeNull();
|
|
1311
|
+
expect(f.supervisor.job(job)?.leaderResult).toBeNull();
|
|
1312
|
+
await f.broker.handle(leaderMessage);
|
|
1313
|
+
const leader = f.client(f.broker.get(leaderPid)!);
|
|
1314
|
+
leader.exit(4);
|
|
1315
|
+
await f.flush();
|
|
1316
|
+
expect(f.supervisor.waitJob(ownerPid, job)).toEqual({ kind: "exited", code: 4, status: 4 });
|
|
1317
|
+
expectErrno(() => f.root.waitJob(1, job), 12);
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
|
|
1321
|
+
test("a locally failed unposted leader remains authoritative for its admitted shared member", async () => {
|
|
1322
|
+
const f = fixture();
|
|
1323
|
+
const ownerPid = f.root.spawn(1, request({ job: -1 }));
|
|
1324
|
+
await f.flush();
|
|
1325
|
+
const owner = f.client(f.broker.get(ownerPid)!);
|
|
1326
|
+
const { fd } = f.source(owner.options.descriptors);
|
|
1327
|
+
let leaderTransport!: WorkerProcessTransport;
|
|
1328
|
+
let memberPid = 0,
|
|
1329
|
+
released = false,
|
|
1330
|
+
failedLeaderJob = 0;
|
|
1331
|
+
const client = new WorkerProcessClient({
|
|
1332
|
+
...owner.options,
|
|
1333
|
+
prepareSpawn() {
|
|
1334
|
+
return {
|
|
1335
|
+
release() {
|
|
1336
|
+
const state = workerProcessState(leaderTransport);
|
|
1337
|
+
expect(controlLoad(state.confirmed, 0)).toBe(1);
|
|
1338
|
+
expect(controlLoad(state.jobConfirmed, 0)).toBe(1);
|
|
1339
|
+
expect(controlLoad(state.jobPending, 0)).toBe(1);
|
|
1340
|
+
released = true;
|
|
1341
|
+
},
|
|
1342
|
+
};
|
|
1343
|
+
},
|
|
1344
|
+
codec: {
|
|
1345
|
+
...f.codec,
|
|
1346
|
+
export(_source, pid) {
|
|
1347
|
+
// The reservation is visible to another live worker before this exporter fails.
|
|
1348
|
+
leaderTransport = { ...f.transport, slot: 2, pid };
|
|
1349
|
+
failedLeaderJob = workerProcessState(leaderTransport).job;
|
|
1350
|
+
memberPid = f.root.spawn(1, request({ job: failedLeaderJob }));
|
|
1351
|
+
throw new Error("local export failed");
|
|
1352
|
+
},
|
|
1353
|
+
},
|
|
1354
|
+
});
|
|
1355
|
+
expect(() => client.spawn(ownerPid, request({ fds: [{ child: 1, parent: fd }] }))).toThrow(
|
|
1356
|
+
"local export failed",
|
|
1357
|
+
);
|
|
1358
|
+
expect(released).toBe(true);
|
|
1359
|
+
expect(() => workerProcessState(leaderTransport)).toThrow();
|
|
1360
|
+
expect(f.messages.length).toBe(1);
|
|
1361
|
+
await f.flush();
|
|
1362
|
+
expect(f.supervisor.get(leaderTransport.pid)).toBeUndefined();
|
|
1363
|
+
expect(f.supervisor.job(failedLeaderJob)).toMatchObject({
|
|
1364
|
+
ownerPid,
|
|
1365
|
+
leaderPid: leaderTransport.pid,
|
|
1366
|
+
foreground: true,
|
|
1367
|
+
leaderResult: null,
|
|
1368
|
+
});
|
|
1369
|
+
expect(f.supervisor.canWaitJob(ownerPid, failedLeaderJob)).toBe(true);
|
|
1370
|
+
const member = f.client(f.broker.get(memberPid)!);
|
|
1371
|
+
member.exit(7);
|
|
1372
|
+
await f.flush();
|
|
1373
|
+
expect(f.supervisor.waitJob(ownerPid, failedLeaderJob)).toEqual({
|
|
1374
|
+
kind: "start-failed",
|
|
1375
|
+
code: 5,
|
|
1376
|
+
error: "EIO",
|
|
1377
|
+
status: null,
|
|
1378
|
+
});
|
|
1379
|
+
});
|
|
1380
|
+
|
|
1381
|
+
test("worker transfer release follows published commit or failed cancellation confirmation", () => {
|
|
1382
|
+
const f = fixture();
|
|
1383
|
+
const order: string[] = [];
|
|
1384
|
+
const client = new WorkerProcessClient({
|
|
1385
|
+
...f.root.options,
|
|
1386
|
+
prepareSpawn() {
|
|
1387
|
+
return {
|
|
1388
|
+
commit() {
|
|
1389
|
+
expect(f.messages.length).toBe(1);
|
|
1390
|
+
order.push("commit");
|
|
1391
|
+
},
|
|
1392
|
+
release() {
|
|
1393
|
+
order.push("release");
|
|
1394
|
+
},
|
|
1395
|
+
};
|
|
1396
|
+
},
|
|
1397
|
+
});
|
|
1398
|
+
client.spawn(1, request());
|
|
1399
|
+
expect(order).toEqual(["commit", "release"]);
|
|
1400
|
+
const failed = new WorkerProcessClient({
|
|
1401
|
+
...f.root.options,
|
|
1402
|
+
postMessage() {
|
|
1403
|
+
throw new Error("publication failed");
|
|
1404
|
+
},
|
|
1405
|
+
prepareSpawn() {
|
|
1406
|
+
return {
|
|
1407
|
+
cancel() {
|
|
1408
|
+
order.push("cancel");
|
|
1409
|
+
},
|
|
1410
|
+
release() {
|
|
1411
|
+
const state = workerProcessState({ ...f.transport, slot: 2, pid: 3 });
|
|
1412
|
+
expect(controlLoad(state.confirmed, 0)).toBe(0);
|
|
1413
|
+
expect(controlLoad(state.jobConfirmed, 0)).toBe(0);
|
|
1414
|
+
expect(controlLoad(state.jobPending, 0)).toBe(1);
|
|
1415
|
+
order.push("failed-release");
|
|
1416
|
+
},
|
|
1417
|
+
};
|
|
1418
|
+
},
|
|
1419
|
+
});
|
|
1420
|
+
expect(() => failed.spawn(1, request())).toThrow("publication failed");
|
|
1421
|
+
expect(order).toEqual(["commit", "release", "failed-release"]);
|
|
1422
|
+
});
|
|
1423
|
+
|
|
1424
|
+
test("broker disposal preserves safe confirmation after listener cleanup without awaiting physical termination", async () => {
|
|
1425
|
+
let finishFence!: () => void, finishTermination!: () => void;
|
|
1426
|
+
const fence = new Promise<void>((resolve) => {
|
|
1427
|
+
finishFence = resolve;
|
|
1428
|
+
});
|
|
1429
|
+
const termination = new Promise<void>((resolve) => {
|
|
1430
|
+
finishTermination = resolve;
|
|
1431
|
+
});
|
|
1432
|
+
let terminationStarted = false,
|
|
1433
|
+
physicallyTerminated = false;
|
|
1434
|
+
const f = fixture({
|
|
1435
|
+
quiesce: () => fence,
|
|
1436
|
+
terminate() {
|
|
1437
|
+
terminationStarted = true;
|
|
1438
|
+
return termination.then(() => {
|
|
1439
|
+
physicallyTerminated = true;
|
|
1440
|
+
});
|
|
1441
|
+
},
|
|
1442
|
+
});
|
|
1443
|
+
const pid = f.root.spawn(1, request());
|
|
1444
|
+
await f.flush();
|
|
1445
|
+
await f.supervisor.start(pid);
|
|
1446
|
+
const transport = f.broker.get(pid)!;
|
|
1447
|
+
const state = workerProcessState(transport);
|
|
1448
|
+
try {
|
|
1449
|
+
f.broker.dispose();
|
|
1450
|
+
// Embeddings may immediately dispose their supervisor and remove every listener too.
|
|
1451
|
+
f.supervisor.dispose();
|
|
1452
|
+
expect(terminationStarted).toBe(false);
|
|
1453
|
+
expect(physicallyTerminated).toBe(false);
|
|
1454
|
+
expect(f.broker.get(pid)).toBeUndefined();
|
|
1455
|
+
expect(f.broker.getIdentity(pid)).toBeUndefined();
|
|
1456
|
+
expect(controlLoad(state.confirmed, 0)).toBe(0);
|
|
1457
|
+
expect(controlLoad(state.jobConfirmed, 0)).toBe(0);
|
|
1458
|
+
expect(f.root.wait(1, pid)).toBeNull();
|
|
1459
|
+
const before = controlLoad(state.wake, 0);
|
|
1460
|
+
finishFence();
|
|
1461
|
+
await fence;
|
|
1462
|
+
await Promise.resolve();
|
|
1463
|
+
expect(terminationStarted).toBe(true);
|
|
1464
|
+
expect(physicallyTerminated).toBe(false);
|
|
1465
|
+
// Supervisor disposal retires the dead parent's safely fenced orphan row.
|
|
1466
|
+
expectErrno(() => controlLoad(state.confirmed), 71);
|
|
1467
|
+
expectErrno(() => controlLoad(state.jobConfirmed), 71);
|
|
1468
|
+
expect(controlLoad(state.jobPending, 0)).toBe(0);
|
|
1469
|
+
expect(controlLoad(state.wake, 0)).toBeGreaterThan(before);
|
|
1470
|
+
expectErrno(() => f.root.wait(1, pid), 12);
|
|
1471
|
+
} finally {
|
|
1472
|
+
finishFence();
|
|
1473
|
+
finishTermination();
|
|
1474
|
+
await termination;
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
|
|
1478
|
+
test("broker disposal remains unconfirmed when the host-work fence fails", async () => {
|
|
1479
|
+
let failFence!: (error: unknown) => void;
|
|
1480
|
+
const fence = new Promise<void>((_resolve, reject) => {
|
|
1481
|
+
failFence = reject;
|
|
1482
|
+
});
|
|
1483
|
+
const f = fixture({ quiesce: () => fence });
|
|
1484
|
+
const pid = f.root.spawn(1, request());
|
|
1485
|
+
await f.flush();
|
|
1486
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
1487
|
+
f.broker.dispose();
|
|
1488
|
+
f.supervisor.dispose();
|
|
1489
|
+
failFence(new Error("fence failed"));
|
|
1490
|
+
await fence.catch(() => {});
|
|
1491
|
+
await Promise.resolve();
|
|
1492
|
+
expect(controlLoad(state.confirmed, 0)).toBe(0);
|
|
1493
|
+
expect(controlLoad(state.jobConfirmed, 0)).toBe(0);
|
|
1494
|
+
expect(f.root.wait(1, pid)).toBeNull();
|
|
1495
|
+
expect(f.broker.getIdentity(pid)).toBeUndefined();
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
test("more than three thousand same-job child lifetimes recycle bounded process slots", async () => {
|
|
1499
|
+
const f = fixture({ capacity: 3 });
|
|
1500
|
+
for (let cycle = 0; cycle < 3101; cycle++) {
|
|
1501
|
+
const pid = f.root.spawn(1, request({ job: f.root.job }));
|
|
1502
|
+
await f.flush();
|
|
1503
|
+
f.supervisor.exit(pid, cycle);
|
|
1504
|
+
expect(f.root.wait(1, pid)?.code).toBe(cycle);
|
|
1505
|
+
await f.flush();
|
|
1506
|
+
expect(f.supervisor.get(pid)).toBeUndefined();
|
|
1507
|
+
expectErrno(() => f.root.wait(1, pid), 12);
|
|
1508
|
+
f.contexts.delete(pid);
|
|
1509
|
+
expect(directorySlots(f.transport.directory)).toHaveLength(1);
|
|
1510
|
+
expect(directoryJobs(f.transport.directory)).toHaveLength(1);
|
|
1511
|
+
expect(Array.from(f.supervisor.table.values())).toHaveLength(1);
|
|
1512
|
+
expect(Reflect.get(f.broker, "transports").size).toBe(1);
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
|
|
1516
|
+
test("more than three thousand distinct job lifetimes recycle process and job slots", async () => {
|
|
1517
|
+
const f = fixture({ capacity: 3 });
|
|
1518
|
+
for (let cycle = 0; cycle < 3101; cycle++) {
|
|
1519
|
+
const pid = f.root.spawn(1, request());
|
|
1520
|
+
const job = f.root.jobOf(pid);
|
|
1521
|
+
await f.flush();
|
|
1522
|
+
f.supervisor.exit(pid, cycle);
|
|
1523
|
+
expect(f.root.waitJob(1, job)?.code).toBe(cycle);
|
|
1524
|
+
await f.flush();
|
|
1525
|
+
f.contexts.delete(pid);
|
|
1526
|
+
expect(directorySlots(f.transport.directory)).toHaveLength(1);
|
|
1527
|
+
expect(directoryJobs(f.transport.directory)).toHaveLength(1);
|
|
1528
|
+
expect(Array.from(f.supervisor.table.values())).toHaveLength(1);
|
|
1529
|
+
expect(f.supervisor.job(job)).toBeUndefined();
|
|
1530
|
+
expect(Reflect.get(f.broker, "transports").size).toBe(1);
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
|
|
1534
|
+
for (const hostOperation of ["wait", "reap", "childExited", "waitForExit"] as const) {
|
|
1535
|
+
test(`host ${hostOperation} rejects shared child collection before the Worker receipt`, async () => {
|
|
1536
|
+
const f = fixture({ capacity: 2 });
|
|
1537
|
+
const pid = f.root.spawn(1, request({ job: f.root.job }));
|
|
1538
|
+
await f.flush();
|
|
1539
|
+
f.supervisor.exit(pid, 7);
|
|
1540
|
+
expect(f.root.wait(1, pid)?.code).toBe(7);
|
|
1541
|
+
expect(f.supervisor.get(pid)?.result?.code).toBe(7); // Receipt deliberately withheld.
|
|
1542
|
+
expectErrno(() => f.supervisor[hostOperation](1, pid), 12);
|
|
1543
|
+
expect(f.supervisor.get(pid)).toBeUndefined();
|
|
1544
|
+
await f.flush();
|
|
1545
|
+
const replacement = f.root.spawn(1, request({ job: f.root.job }));
|
|
1546
|
+
await f.flush();
|
|
1547
|
+
expect(replacement).toBeGreaterThan(pid);
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
test("a host consuming claim rejects a Worker that wins after host observation", async () => {
|
|
1552
|
+
const f = fixture({ capacity: 2 });
|
|
1553
|
+
const pid = f.root.spawn(1, request({ job: f.root.job }));
|
|
1554
|
+
await f.flush();
|
|
1555
|
+
f.supervisor.exit(pid, 8);
|
|
1556
|
+
let raced = false;
|
|
1557
|
+
const stop = f.supervisor.registerChildAccess((target, consume) => {
|
|
1558
|
+
if (target === pid && !consume && !raced) {
|
|
1559
|
+
raced = true;
|
|
1560
|
+
expect(f.root.wait(1, pid)?.code).toBe(8);
|
|
1561
|
+
}
|
|
1562
|
+
return true;
|
|
1563
|
+
});
|
|
1564
|
+
try {
|
|
1565
|
+
expectErrno(() => f.supervisor.reap(1, pid), 12);
|
|
1566
|
+
} finally {
|
|
1567
|
+
stop();
|
|
1568
|
+
}
|
|
1569
|
+
expect(raced).toBe(true);
|
|
1570
|
+
});
|
|
1571
|
+
|
|
1572
|
+
test("collected process and job controls fail immediately before their slots are reused", async () => {
|
|
1573
|
+
const f = fixture({ capacity: 2 });
|
|
1574
|
+
const pid = f.root.spawn(1, request());
|
|
1575
|
+
await f.flush();
|
|
1576
|
+
const old = workerProcessState(f.broker.get(pid)!);
|
|
1577
|
+
f.supervisor.exit(pid, 0);
|
|
1578
|
+
expect(f.supervisor.wait(1, pid)?.code).toBe(0);
|
|
1579
|
+
for (const word of [
|
|
1580
|
+
old.confirmed,
|
|
1581
|
+
old.jobConfirmed,
|
|
1582
|
+
old.controlParent,
|
|
1583
|
+
old.signals.interrupt,
|
|
1584
|
+
old.signals.requestedSignal,
|
|
1585
|
+
old.signals.signalState,
|
|
1586
|
+
]) {
|
|
1587
|
+
expectErrno(() => controlLoad(word), 71);
|
|
1588
|
+
expectErrno(() => controlStore(word, 0, 9), 71);
|
|
1589
|
+
expectErrno(() => controlCas(word, 0, 0, 9), 71);
|
|
1590
|
+
expectErrno(() => controlExchange(word, 0, 9), 71);
|
|
1591
|
+
expectErrno(() => controlAdd(word, 0, 1), 71);
|
|
1592
|
+
expectErrno(() => controlWait(word, 0, 0, 0), 71);
|
|
1593
|
+
expectErrno(() => controlNotify(word), 71);
|
|
1594
|
+
}
|
|
1595
|
+
expect(controlLoad(old.jobPending)).toBe(0);
|
|
1596
|
+
expect(f.supervisor.waitJob(1, old.job)?.code).toBe(0);
|
|
1597
|
+
for (const word of [old.jobPending, old.jobControlParent]) {
|
|
1598
|
+
expectErrno(() => controlLoad(word), 71);
|
|
1599
|
+
expectErrno(() => controlStore(word, 0, 9), 71);
|
|
1600
|
+
expectErrno(() => controlWait(word, 0, 0, 0), 71);
|
|
1601
|
+
expectErrno(() => controlNotify(word), 71);
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
|
|
1605
|
+
test("captured signals, outcomes and confirmation cells cannot write a reused process slot", async () => {
|
|
1606
|
+
const f = fixture({ capacity: 2 });
|
|
1607
|
+
const oldPid = f.root.spawn(1, request({ job: f.root.job }));
|
|
1608
|
+
await f.flush();
|
|
1609
|
+
const oldTransport = f.broker.get(oldPid)!;
|
|
1610
|
+
const old = workerProcessState(oldTransport);
|
|
1611
|
+
f.supervisor.exit(oldPid, Number.MAX_SAFE_INTEGER);
|
|
1612
|
+
const returned = f.supervisor.reap(1, oldPid);
|
|
1613
|
+
await f.flush();
|
|
1614
|
+
const pid = f.root.spawn(1, request({ job: f.root.job }));
|
|
1615
|
+
await f.flush();
|
|
1616
|
+
const next = workerProcessState(f.broker.get(pid)!);
|
|
1617
|
+
expect(next.slot).toBe(old.slot);
|
|
1618
|
+
expectErrno(() => controlStore(old.confirmed, 0, 1), 71);
|
|
1619
|
+
expectErrno(() => controlStore(old.signals.interrupt, 0, 9), 71);
|
|
1620
|
+
expectErrno(() => controlStore(old.signals.requestedSignal, 0, 9), 71);
|
|
1621
|
+
expectErrno(
|
|
1622
|
+
() => setSignalDisposition(old.signals.signalState, 15, SignalDisposition.HANDLE),
|
|
1623
|
+
71,
|
|
1624
|
+
);
|
|
1625
|
+
expectErrno(() => claimOutcome(old.signals.outcome, { kind: "signaled", code: 9 }), 71);
|
|
1626
|
+
expectErrno(() => readOutcome(old.signals.outcome), 71);
|
|
1627
|
+
expectErrno(() => workerProcessState(oldTransport), 71);
|
|
1628
|
+
expect(readOutcome(next.signals.outcome)).toBeNull();
|
|
1629
|
+
expect(controlLoad(next.confirmed)).toBe(0);
|
|
1630
|
+
expect(controlLoad(next.signals.interrupt)).toBe(0);
|
|
1631
|
+
expect(returned.code).toBe(Number.MAX_SAFE_INTEGER);
|
|
1632
|
+
});
|
|
1633
|
+
|
|
1634
|
+
function readyForCollection(transport: WorkerProcessTransport): void {
|
|
1635
|
+
const state = workerProcessState(transport);
|
|
1636
|
+
captureNativeReturn(transport)();
|
|
1637
|
+
claimOutcome(state.signals.outcome, { kind: "exited", code: 0 });
|
|
1638
|
+
controlStore(state.confirmed, 0, 1);
|
|
1639
|
+
controlStore(state.jobConfirmed, 0, 1);
|
|
1640
|
+
state.jobPending.add(0, -1);
|
|
1641
|
+
if (state.pid === state.jobLeaderPid) claimOutcome(state.jobOutcome, { kind: "exited", code: 0 });
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
test("concurrent ancestor collectors help frozen forwarding edges without resurrecting a retired ancestor", () => {
|
|
1645
|
+
const root = createWorkerProcessTransport({ capacity: 4 });
|
|
1646
|
+
const a = { ...root, ...reserveDirectoryProcess(root, 2, 1, 1, 1, 0) };
|
|
1647
|
+
const b = { ...root, ...reserveDirectoryProcess(a, 3, 2, 1, 1, 0) };
|
|
1648
|
+
const c = { ...root, ...reserveDirectoryProcess(b, 4, 3, 1, 1, 0) };
|
|
1649
|
+
readyForCollection(a);
|
|
1650
|
+
readyForCollection(b);
|
|
1651
|
+
const edge = workerProcessState(b).controlParent;
|
|
1652
|
+
const original = Atomics.compareExchange;
|
|
1653
|
+
let raced = false;
|
|
1654
|
+
Atomics.compareExchange = ((
|
|
1655
|
+
array: BigInt64Array,
|
|
1656
|
+
index: number,
|
|
1657
|
+
expected: bigint,
|
|
1658
|
+
replacement: bigint,
|
|
1659
|
+
) => {
|
|
1660
|
+
const previous = original(array, index, expected, replacement);
|
|
1661
|
+
if (
|
|
1662
|
+
!raced &&
|
|
1663
|
+
array.buffer === edge.buffer &&
|
|
1664
|
+
array.byteOffset === edge.byteOffset &&
|
|
1665
|
+
replacement === packedControl(3, -3)
|
|
1666
|
+
) {
|
|
1667
|
+
raced = true;
|
|
1668
|
+
collectDirectoryProcess(a);
|
|
1669
|
+
}
|
|
1670
|
+
return previous;
|
|
1671
|
+
}) as typeof Atomics.compareExchange;
|
|
1672
|
+
try {
|
|
1673
|
+
collectDirectoryProcess(b);
|
|
1674
|
+
} finally {
|
|
1675
|
+
Atomics.compareExchange = original;
|
|
1676
|
+
}
|
|
1677
|
+
expect(raced).toBe(true);
|
|
1678
|
+
expect(controlLoad(workerProcessState(c).controlParent)).toBe(1);
|
|
1679
|
+
expect(directorySlots(root.directory)).toHaveLength(2);
|
|
1680
|
+
});
|
|
1681
|
+
|
|
1682
|
+
test("a job collector completes when an individual collector wins after its slot snapshot", () => {
|
|
1683
|
+
const root = createWorkerProcessTransport({ capacity: 3 });
|
|
1684
|
+
const leader = { ...root, ...reserveDirectoryProcess(root, 2, 1, 2, 1) };
|
|
1685
|
+
const member = {
|
|
1686
|
+
...root,
|
|
1687
|
+
...reserveDirectoryProcess(leader, 3, 2, 2, 1, workerProcessState(leader).jobSlot),
|
|
1688
|
+
};
|
|
1689
|
+
readyForCollection(leader);
|
|
1690
|
+
readyForCollection(member);
|
|
1691
|
+
const state = workerProcessState(member);
|
|
1692
|
+
const original = Atomics.load;
|
|
1693
|
+
let raced = false;
|
|
1694
|
+
Atomics.load = ((array: BigInt64Array, index: number) => {
|
|
1695
|
+
const value = original(array, index);
|
|
1696
|
+
if (
|
|
1697
|
+
!raced &&
|
|
1698
|
+
array instanceof BigInt64Array &&
|
|
1699
|
+
index === 0 &&
|
|
1700
|
+
array.byteOffset === state.signals.outcome.byteOffset - 5 * 8 &&
|
|
1701
|
+
Number(BigInt.asIntN(32, original(state.jobPending.cells, 0))) === -1
|
|
1702
|
+
) {
|
|
1703
|
+
raced = true;
|
|
1704
|
+
collectDirectoryProcess(member);
|
|
1705
|
+
}
|
|
1706
|
+
return value;
|
|
1707
|
+
}) as typeof Atomics.load;
|
|
1708
|
+
try {
|
|
1709
|
+
expect(collectDirectoryJob(root.directory, workerProcessState(leader).jobSlot, 2).code).toBe(0);
|
|
1710
|
+
} finally {
|
|
1711
|
+
Atomics.load = original;
|
|
1712
|
+
}
|
|
1713
|
+
expect(raced).toBe(true);
|
|
1714
|
+
expect(directorySlots(root.directory)).toHaveLength(1);
|
|
1715
|
+
expect(directoryJobs(root.directory)).toHaveLength(1);
|
|
1716
|
+
});
|
|
1717
|
+
|
|
1718
|
+
test("a pending wait resolves its captured immutable result after another collector reuses the slot", async () => {
|
|
1719
|
+
const f = fixture({ capacity: 2 });
|
|
1720
|
+
const pid = f.root.spawn(1, request({ job: f.root.job }));
|
|
1721
|
+
await f.flush();
|
|
1722
|
+
const transport = f.broker.get(pid)!;
|
|
1723
|
+
const waiting = f.supervisor.waitForExit(1, pid);
|
|
1724
|
+
f.supervisor.exit(pid, 47);
|
|
1725
|
+
const selected = f.supervisor.reap(1, pid);
|
|
1726
|
+
await f.flush();
|
|
1727
|
+
const replacement = f.root.spawn(1, request({ job: f.root.job }));
|
|
1728
|
+
await f.flush();
|
|
1729
|
+
const state = workerProcessState(f.broker.get(replacement)!);
|
|
1730
|
+
expect(state.slot).toBe(transport.slot);
|
|
1731
|
+
expect(await waiting).toEqual({ kind: "exited", code: 47, status: 47 });
|
|
1732
|
+
expect(Object.isFrozen(selected)).toBe(true);
|
|
1733
|
+
expectErrno(() => f.root.wait(1, pid), 12);
|
|
1734
|
+
expectErrno(() => confirmWorkerProcessJob(transport), 71);
|
|
1735
|
+
expect(readOutcome(state.signals.outcome)).toBeNull();
|
|
1736
|
+
expect(controlLoad(state.confirmed)).toBe(0);
|
|
1737
|
+
});
|
|
1738
|
+
|
|
1739
|
+
test("a pending launch stops only its captured old handle while another slot is used", async () => {
|
|
1740
|
+
let finishLaunch!: (handle: ProcessHandle) => void;
|
|
1741
|
+
let first = true,
|
|
1742
|
+
oldStops = 0,
|
|
1743
|
+
newStops = 0;
|
|
1744
|
+
let enteredLaunch!: () => void;
|
|
1745
|
+
const entered = new Promise<void>((resolve) => {
|
|
1746
|
+
enteredLaunch = resolve;
|
|
1747
|
+
});
|
|
1748
|
+
const pending = new Promise<ProcessHandle>((resolve) => {
|
|
1749
|
+
finishLaunch = resolve;
|
|
1750
|
+
});
|
|
1751
|
+
const f = fixture({
|
|
1752
|
+
capacity: 3,
|
|
1753
|
+
launch() {
|
|
1754
|
+
if (first) {
|
|
1755
|
+
first = false;
|
|
1756
|
+
enteredLaunch();
|
|
1757
|
+
return pending;
|
|
1758
|
+
}
|
|
1759
|
+
return {
|
|
1760
|
+
terminate() {
|
|
1761
|
+
newStops++;
|
|
1762
|
+
},
|
|
1763
|
+
};
|
|
1764
|
+
},
|
|
1765
|
+
});
|
|
1766
|
+
const pid = f.root.spawn(1, request({ job: f.root.job }));
|
|
1767
|
+
await f.flush();
|
|
1768
|
+
const starting = f.supervisor.start(pid);
|
|
1769
|
+
cleanups.push(() =>
|
|
1770
|
+
finishLaunch({
|
|
1771
|
+
terminate() {
|
|
1772
|
+
oldStops++;
|
|
1773
|
+
},
|
|
1774
|
+
}),
|
|
1775
|
+
);
|
|
1776
|
+
await entered;
|
|
1777
|
+
const context = f.contexts.get(pid)!;
|
|
1778
|
+
expect(context).toBeDefined();
|
|
1779
|
+
f.supervisor.exit(pid, 8);
|
|
1780
|
+
f.supervisor.reap(1, pid);
|
|
1781
|
+
const replacement = f.root.spawn(1, request({ job: f.root.job }));
|
|
1782
|
+
await f.flush();
|
|
1783
|
+
await f.supervisor.start(replacement);
|
|
1784
|
+
finishLaunch({
|
|
1785
|
+
terminate() {
|
|
1786
|
+
oldStops++;
|
|
1787
|
+
},
|
|
1788
|
+
});
|
|
1789
|
+
await starting;
|
|
1790
|
+
expect(oldStops).toBe(1);
|
|
1791
|
+
expect(newStops).toBe(0);
|
|
1792
|
+
context.exit(99);
|
|
1793
|
+
expect(readOutcome(workerProcessState(f.broker.get(replacement)!).signals.outcome)).toBeNull();
|
|
1794
|
+
expect(f.supervisor.get(replacement)?.result).toBeNull();
|
|
1795
|
+
});
|
|
1796
|
+
|
|
1797
|
+
test("host waits in an early exit observer return before native capacity is reusable", async () => {
|
|
1798
|
+
let pid = 0,
|
|
1799
|
+
replacement = 0;
|
|
1800
|
+
const f = fixture({
|
|
1801
|
+
capacity: 2,
|
|
1802
|
+
beforeActivation(supervisor) {
|
|
1803
|
+
supervisor.onChildExit((event) => {
|
|
1804
|
+
if (event.pid !== pid) return;
|
|
1805
|
+
expect(supervisor.wait(1, pid)?.code).toBe(21);
|
|
1806
|
+
expectErrno(() => f.root.spawn(1, request({ job: f.root.job })), ProcessErrno.AGAIN);
|
|
1807
|
+
});
|
|
1808
|
+
},
|
|
1809
|
+
});
|
|
1810
|
+
pid = f.root.spawn(1, request({ job: f.root.job }));
|
|
1811
|
+
await f.flush();
|
|
1812
|
+
const waiting = f.supervisor.waitForExit(1, pid);
|
|
1813
|
+
f.supervisor.exit(pid, 21);
|
|
1814
|
+
expect(await waiting).toEqual({ kind: "exited", code: 21, status: 21 });
|
|
1815
|
+
expect(f.broker.get(pid)).toBeUndefined();
|
|
1816
|
+
await f.flush();
|
|
1817
|
+
replacement = f.root.spawn(1, request({ job: f.root.job }));
|
|
1818
|
+
expect(replacement).toBeGreaterThan(pid);
|
|
1819
|
+
await f.flush();
|
|
1820
|
+
expect(directorySlots(f.transport.directory)).toHaveLength(2);
|
|
1821
|
+
});
|
|
1822
|
+
|
|
1823
|
+
test("numeric admitted identities cannot reuse collected rows but captured out-of-order admissions remain valid", async () => {
|
|
1824
|
+
const f = fixture({ capacity: 3 });
|
|
1825
|
+
const earlier = f.root.spawn(1, request());
|
|
1826
|
+
const held = f.messages.shift()!;
|
|
1827
|
+
const earlierJob = workerProcessState(held.transport).job;
|
|
1828
|
+
const later = f.root.spawn(1, request());
|
|
1829
|
+
await f.flush();
|
|
1830
|
+
const oldTransport = f.broker.get(later)!;
|
|
1831
|
+
const old = workerProcessState(oldTransport);
|
|
1832
|
+
f.supervisor.exit(later, 0);
|
|
1833
|
+
const oldJob = old.job;
|
|
1834
|
+
expect(f.root.waitJob(1, oldJob)?.code).toBe(0);
|
|
1835
|
+
await f.flush();
|
|
1836
|
+
expect(() =>
|
|
1837
|
+
f.supervisor.reserveAdmittedSpawn(1, request({ job: f.root.job }), {
|
|
1838
|
+
processIdentity: old.processIdentity,
|
|
1839
|
+
pid: later,
|
|
1840
|
+
job: f.root.job,
|
|
1841
|
+
}),
|
|
1842
|
+
).toThrow();
|
|
1843
|
+
expect(() =>
|
|
1844
|
+
f.supervisor.reserveAdmittedSpawn(1, request({ job: f.root.job }), {
|
|
1845
|
+
processIdentity: old.processIdentity,
|
|
1846
|
+
pid: later,
|
|
1847
|
+
job: f.root.job,
|
|
1848
|
+
outcome: old.signals.outcome,
|
|
1849
|
+
}),
|
|
1850
|
+
).toThrow();
|
|
1851
|
+
expect(() => f.supervisor.createRoot({ pid: later, outcome: old.signals.outcome })).toThrow();
|
|
1852
|
+
expect(() => f.supervisor.table.createJob(1, true, oldJob)).toThrow();
|
|
1853
|
+
await f.broker.handle(held);
|
|
1854
|
+
expect(f.supervisor.get(earlier)?.job).toBe(earlierJob);
|
|
1855
|
+
expect(earlier).toBeLessThan(later);
|
|
1856
|
+
expect(earlierJob).toBeLessThan(oldJob);
|
|
1857
|
+
});
|
|
1858
|
+
|
|
1859
|
+
for (const stopAt of ["seal", "job-retiring", "member-retiring", "member-freed"] as const) {
|
|
1860
|
+
test(`another host pump completes job retirement after collector stops at ${stopAt}`, async () => {
|
|
1861
|
+
const f = fixture({ capacity: 4 });
|
|
1862
|
+
const leader = f.root.spawn(1, request());
|
|
1863
|
+
await f.flush();
|
|
1864
|
+
const leaderTransport = f.broker.get(leader)!,
|
|
1865
|
+
client = f.client(leaderTransport);
|
|
1866
|
+
const member = client.spawn(leader, request({ job: client.job }));
|
|
1867
|
+
await f.flush();
|
|
1868
|
+
const memberClient = f.client(f.broker.get(member)!);
|
|
1869
|
+
const descendant = memberClient.spawn(member, request({ job: -1 }));
|
|
1870
|
+
await f.flush();
|
|
1871
|
+
f.supervisor.exit(member, 2);
|
|
1872
|
+
f.supervisor.exit(leader, 9);
|
|
1873
|
+
const group = directoryJob(f.transport.directory, workerProcessState(leaderTransport).jobSlot);
|
|
1874
|
+
const original = Atomics.compareExchange;
|
|
1875
|
+
const stopped = new Error("collector terminated");
|
|
1876
|
+
let interrupted = false;
|
|
1877
|
+
const identityOffset = workerProcessState(leaderTransport).signals.outcome.byteOffset - 5 * 8;
|
|
1878
|
+
const groupOffset = group.outcome.byteOffset - 3 * 8;
|
|
1879
|
+
Atomics.compareExchange = ((
|
|
1880
|
+
array: BigInt64Array,
|
|
1881
|
+
index: number,
|
|
1882
|
+
expected: bigint,
|
|
1883
|
+
replacement: bigint,
|
|
1884
|
+
) => {
|
|
1885
|
+
const value = original(array, index, expected, replacement);
|
|
1886
|
+
if (
|
|
1887
|
+
!interrupted &&
|
|
1888
|
+
array instanceof BigInt64Array &&
|
|
1889
|
+
array.buffer === f.transport.directory &&
|
|
1890
|
+
index === 0 &&
|
|
1891
|
+
((stopAt === "seal" &&
|
|
1892
|
+
array.byteOffset === group.pending.byteOffset &&
|
|
1893
|
+
replacement === packedControl(group.id, -1)) ||
|
|
1894
|
+
(stopAt === "job-retiring" &&
|
|
1895
|
+
array.byteOffset === groupOffset &&
|
|
1896
|
+
replacement === packedControl(group.id, 3)) ||
|
|
1897
|
+
(stopAt === "member-retiring" &&
|
|
1898
|
+
array.byteOffset === identityOffset &&
|
|
1899
|
+
replacement === packedControl(leader, 3)) ||
|
|
1900
|
+
(stopAt === "member-freed" &&
|
|
1901
|
+
array.byteOffset === identityOffset &&
|
|
1902
|
+
expected === packedControl(leader, 4) &&
|
|
1903
|
+
replacement === 0n))
|
|
1904
|
+
) {
|
|
1905
|
+
interrupted = true;
|
|
1906
|
+
throw stopped;
|
|
1907
|
+
}
|
|
1908
|
+
return value;
|
|
1909
|
+
}) as typeof Atomics.compareExchange;
|
|
1910
|
+
try {
|
|
1911
|
+
expect(() => collectDirectoryJob(f.transport.directory, group.slot, group.id)).toThrow(
|
|
1912
|
+
stopped,
|
|
1913
|
+
);
|
|
1914
|
+
} finally {
|
|
1915
|
+
Atomics.compareExchange = original;
|
|
1916
|
+
}
|
|
1917
|
+
expect(interrupted).toBe(true);
|
|
1918
|
+
f.broker.pump(); // No consuming worker receipt was ever posted.
|
|
1919
|
+
expect(f.supervisor.job(group.id)).toBeUndefined();
|
|
1920
|
+
expect(f.broker.get(leader)).toBeUndefined();
|
|
1921
|
+
expect(f.broker.get(member)).toBeUndefined();
|
|
1922
|
+
expect(directorySlots(f.transport.directory)).toHaveLength(2);
|
|
1923
|
+
expect(directoryJobs(f.transport.directory)).toHaveLength(2);
|
|
1924
|
+
expect(f.root.canSignal(1, descendant)).toBe(true);
|
|
1925
|
+
f.root.killJob(f.root.jobOf(descendant), 9);
|
|
1926
|
+
await f.flush();
|
|
1927
|
+
// The independent descendant job remains separately consumable after its parent job.
|
|
1928
|
+
const remaining = Array.from(directoryGroups(f.transport.directory)).find(
|
|
1929
|
+
(candidate) => candidate.id !== f.root.job,
|
|
1930
|
+
)!;
|
|
1931
|
+
expect(f.root.waitJob(1, remaining.id)?.status).toBe(137);
|
|
1932
|
+
await f.flush();
|
|
1933
|
+
expect(directorySlots(f.transport.directory)).toEqual([0]);
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
test("host metadata reconciles a consumed job without the worker's final reap notification", async () => {
|
|
1938
|
+
const f = fixture({ capacity: 2 });
|
|
1939
|
+
const pid = f.root.spawn(1, request());
|
|
1940
|
+
await f.flush();
|
|
1941
|
+
const job = f.root.jobOf(pid);
|
|
1942
|
+
f.supervisor.exit(pid, 18);
|
|
1943
|
+
const silent = new WorkerProcessClient({ ...f.root.options, postMessage() {} });
|
|
1944
|
+
expect(silent.waitJob(1, job)?.code).toBe(18);
|
|
1945
|
+
expect(f.supervisor.job(job)).toBeDefined();
|
|
1946
|
+
f.broker.pump();
|
|
1947
|
+
expect(f.supervisor.job(job)).toBeUndefined();
|
|
1948
|
+
expect(f.broker.get(pid)).toBeUndefined();
|
|
1949
|
+
expect(Array.from(f.supervisor.table.values())).toHaveLength(1);
|
|
1950
|
+
const next = f.root.spawn(1, request());
|
|
1951
|
+
await f.flush();
|
|
1952
|
+
expect(next).toBeGreaterThan(pid);
|
|
1953
|
+
});
|
|
1954
|
+
|
|
1955
|
+
test("captured directory enumeration skips an unrelated process collected during its identity read", () => {
|
|
1956
|
+
const root = createWorkerProcessTransport({ capacity: 3 });
|
|
1957
|
+
const old = { ...root, ...reserveDirectoryProcess(root, 2, 1, 1, 1, 0) };
|
|
1958
|
+
const live = { ...root, ...reserveDirectoryProcess(root, 3, 1, 1, 1, 0) };
|
|
1959
|
+
readyForCollection(old);
|
|
1960
|
+
const oldOffset = workerProcessState(old).signals.outcome.byteOffset - 5 * 8;
|
|
1961
|
+
const original = Atomics.load;
|
|
1962
|
+
let raced = false;
|
|
1963
|
+
Atomics.load = ((array: BigInt64Array, index: number) => {
|
|
1964
|
+
const value = original(array, index);
|
|
1965
|
+
if (
|
|
1966
|
+
!raced &&
|
|
1967
|
+
array instanceof BigInt64Array &&
|
|
1968
|
+
array.buffer === root.directory &&
|
|
1969
|
+
array.byteOffset === oldOffset &&
|
|
1970
|
+
index === 0
|
|
1971
|
+
) {
|
|
1972
|
+
raced = true;
|
|
1973
|
+
collectDirectoryProcess(old);
|
|
1974
|
+
}
|
|
1975
|
+
return value;
|
|
1976
|
+
}) as typeof Atomics.load;
|
|
1977
|
+
try {
|
|
1978
|
+
expect(Array.from(directoryProcesses(root.directory), (state) => state.pid)).toEqual([
|
|
1979
|
+
1,
|
|
1980
|
+
live.pid,
|
|
1981
|
+
]);
|
|
1982
|
+
} finally {
|
|
1983
|
+
Atomics.load = original;
|
|
1984
|
+
}
|
|
1985
|
+
expect(raced).toBe(true);
|
|
1986
|
+
});
|
|
1987
|
+
|
|
1988
|
+
test("job lookup skips a different job collected during its captured header read", () => {
|
|
1989
|
+
const root = createWorkerProcessTransport({ capacity: 3 });
|
|
1990
|
+
const old = { ...root, ...reserveDirectoryProcess(root, 2, 1, 2, 1) };
|
|
1991
|
+
const live = { ...root, ...reserveDirectoryProcess(root, 3, 1, 3, 1) };
|
|
1992
|
+
readyForCollection(old);
|
|
1993
|
+
const state = workerProcessState(old),
|
|
1994
|
+
header = state.jobOutcome.byteOffset - 3 * 8;
|
|
1995
|
+
const original = Atomics.load;
|
|
1996
|
+
let raced = false;
|
|
1997
|
+
Atomics.load = ((array: BigInt64Array, index: number) => {
|
|
1998
|
+
const value = original(array, index);
|
|
1999
|
+
if (
|
|
2000
|
+
!raced &&
|
|
2001
|
+
array instanceof BigInt64Array &&
|
|
2002
|
+
array.buffer === root.directory &&
|
|
2003
|
+
array.byteOffset === header &&
|
|
2004
|
+
index === 0
|
|
2005
|
+
) {
|
|
2006
|
+
raced = true;
|
|
2007
|
+
collectDirectoryJob(root.directory, state.jobSlot, state.job);
|
|
2008
|
+
}
|
|
2009
|
+
return value;
|
|
2010
|
+
}) as typeof Atomics.load;
|
|
2011
|
+
try {
|
|
2012
|
+
expect(findDirectoryJob(root.directory, 3)?.leaderPid).toBe(live.pid);
|
|
2013
|
+
} finally {
|
|
2014
|
+
Atomics.load = original;
|
|
2015
|
+
}
|
|
2016
|
+
expect(raced).toBe(true);
|
|
2017
|
+
});
|
|
2018
|
+
|
|
2019
|
+
test("process and job authorization follow a retiring ancestor before its forwarding scan", async () => {
|
|
2020
|
+
const f = fixture({ capacity: 3 });
|
|
2021
|
+
const parent = f.root.spawn(1, request());
|
|
2022
|
+
await f.flush();
|
|
2023
|
+
const parentTransport = f.broker.get(parent)!,
|
|
2024
|
+
client = f.client(parentTransport);
|
|
2025
|
+
const child = client.spawn(parent, request({ job: -1 }));
|
|
2026
|
+
await f.flush();
|
|
2027
|
+
const job = f.root.jobOf(child);
|
|
2028
|
+
f.supervisor.exit(parent, 0);
|
|
2029
|
+
const original = Atomics.compareExchange;
|
|
2030
|
+
let raced = false;
|
|
2031
|
+
const identity = workerProcessState(parentTransport).signals.outcome.byteOffset - 5 * 8;
|
|
2032
|
+
Atomics.compareExchange = ((
|
|
2033
|
+
array: BigInt64Array,
|
|
2034
|
+
index: number,
|
|
2035
|
+
expected: bigint,
|
|
2036
|
+
replacement: bigint,
|
|
2037
|
+
) => {
|
|
2038
|
+
const previous = original(array, index, expected, replacement);
|
|
2039
|
+
if (
|
|
2040
|
+
!raced &&
|
|
2041
|
+
array instanceof BigInt64Array &&
|
|
2042
|
+
array.buffer.byteLength === f.transport.directory.byteLength &&
|
|
2043
|
+
array.byteOffset === identity &&
|
|
2044
|
+
replacement === packedControl(parent, 3)
|
|
2045
|
+
) {
|
|
2046
|
+
raced = true;
|
|
2047
|
+
expect(f.root.canSignal(1, child)).toBe(true);
|
|
2048
|
+
expect(f.root.jobEmpty(1, job)).toBe(false);
|
|
2049
|
+
expect(f.root.canSignalJob(1, job)).toBe(true);
|
|
2050
|
+
}
|
|
2051
|
+
return previous;
|
|
2052
|
+
}) as typeof Atomics.compareExchange;
|
|
2053
|
+
try {
|
|
2054
|
+
f.supervisor.reap(1, parent);
|
|
2055
|
+
} finally {
|
|
2056
|
+
Atomics.compareExchange = original;
|
|
2057
|
+
}
|
|
2058
|
+
expect(raced).toBe(true);
|
|
2059
|
+
f.root.killJob(job, 9);
|
|
2060
|
+
await f.flush();
|
|
2061
|
+
expect(f.root.waitJob(1, job)?.status).toBe(137);
|
|
2062
|
+
await f.flush();
|
|
2063
|
+
});
|
|
2064
|
+
|
|
2065
|
+
test("collecting a captured completed member cannot interrupt signal delivery to live job members", async () => {
|
|
2066
|
+
const f = fixture({ capacity: 3 });
|
|
2067
|
+
const old = f.root.spawn(1, request({ job: f.root.job }));
|
|
2068
|
+
const live = f.root.spawn(1, request({ job: f.root.job }));
|
|
2069
|
+
await f.flush();
|
|
2070
|
+
f.supervisor.exit(old, 4);
|
|
2071
|
+
const outcome = workerProcessState(f.broker.get(old)!).signals.outcome;
|
|
2072
|
+
const original = Atomics.load;
|
|
2073
|
+
let raced = false;
|
|
2074
|
+
Atomics.load = ((array: BigInt64Array, index: number) => {
|
|
2075
|
+
const value = original(array, index);
|
|
2076
|
+
if (
|
|
2077
|
+
!raced &&
|
|
2078
|
+
array instanceof BigInt64Array &&
|
|
2079
|
+
array.buffer.byteLength === outcome.buffer.byteLength &&
|
|
2080
|
+
array.byteOffset === outcome.byteOffset &&
|
|
2081
|
+
index === 0
|
|
2082
|
+
) {
|
|
2083
|
+
raced = true;
|
|
2084
|
+
f.supervisor.reap(1, old);
|
|
2085
|
+
}
|
|
2086
|
+
return value;
|
|
2087
|
+
}) as typeof Atomics.load;
|
|
2088
|
+
try {
|
|
2089
|
+
expect(() => f.root.killJob(f.root.job, 15)).not.toThrow();
|
|
2090
|
+
} finally {
|
|
2091
|
+
Atomics.load = original;
|
|
2092
|
+
}
|
|
2093
|
+
expect(raced).toBe(true);
|
|
2094
|
+
expect(readOutcome(workerProcessState(f.broker.get(live)!).signals.outcome)?.status).toBe(143);
|
|
2095
|
+
});
|
|
2096
|
+
|
|
2097
|
+
test("large job retirement forwards the whole group with linear directory reads", () => {
|
|
2098
|
+
const root = createWorkerProcessTransport({ capacity: 258 });
|
|
2099
|
+
const leader = { ...root, ...reserveDirectoryProcess(root, 2, 1, 2, 1) };
|
|
2100
|
+
const jobSlot = workerProcessState(leader).jobSlot;
|
|
2101
|
+
const members = [leader];
|
|
2102
|
+
for (let pid = 3; pid <= 257; pid++)
|
|
2103
|
+
members.push({ ...root, ...reserveDirectoryProcess(leader, pid, 2, 2, 1, jobSlot) });
|
|
2104
|
+
const orphan = {
|
|
2105
|
+
...root,
|
|
2106
|
+
...reserveDirectoryProcess(members[members.length - 1]!, 258, 257, 3, 257),
|
|
2107
|
+
};
|
|
2108
|
+
for (const member of members) readyForCollection(member);
|
|
2109
|
+
const original = Atomics.load;
|
|
2110
|
+
let reads = 0;
|
|
2111
|
+
Atomics.load = ((array: BigInt64Array, index: number) => {
|
|
2112
|
+
reads++;
|
|
2113
|
+
return original(array, index);
|
|
2114
|
+
}) as typeof Atomics.load;
|
|
2115
|
+
try {
|
|
2116
|
+
expect(collectDirectoryJob(root.directory, jobSlot, 2)?.code).toBe(0);
|
|
2117
|
+
} finally {
|
|
2118
|
+
Atomics.load = original;
|
|
2119
|
+
}
|
|
2120
|
+
expect(reads).toBeLessThan(258 * 50);
|
|
2121
|
+
expect(directorySlots(root.directory)).toHaveLength(2);
|
|
2122
|
+
expect(controlLoad(workerProcessState(orphan).controlParent)).toBe(1);
|
|
2123
|
+
});
|
|
2124
|
+
|
|
2125
|
+
test("job recovery after partial freeing preserves internal-chain forwarding destinations", () => {
|
|
2126
|
+
const root = createWorkerProcessTransport({ capacity: 4 });
|
|
2127
|
+
const leader = { ...root, ...reserveDirectoryProcess(root, 2, 1, 2, 1) };
|
|
2128
|
+
const jobSlot = workerProcessState(leader).jobSlot;
|
|
2129
|
+
const member = { ...root, ...reserveDirectoryProcess(leader, 3, 2, 2, 1, jobSlot) };
|
|
2130
|
+
const descendant = { ...root, ...reserveDirectoryProcess(member, 4, 3, 3, 3) };
|
|
2131
|
+
readyForCollection(leader);
|
|
2132
|
+
readyForCollection(member);
|
|
2133
|
+
const original = Atomics.compareExchange;
|
|
2134
|
+
const interrupted = new Error("terminated after first member free");
|
|
2135
|
+
let stopped = false;
|
|
2136
|
+
const identity = workerProcessState(leader).signals.outcome.byteOffset - 5 * 8;
|
|
2137
|
+
Atomics.compareExchange = ((
|
|
2138
|
+
array: BigInt64Array,
|
|
2139
|
+
index: number,
|
|
2140
|
+
expected: bigint,
|
|
2141
|
+
replacement: bigint,
|
|
2142
|
+
) => {
|
|
2143
|
+
const value = original(array, index, expected, replacement);
|
|
2144
|
+
if (
|
|
2145
|
+
!stopped &&
|
|
2146
|
+
array instanceof BigInt64Array &&
|
|
2147
|
+
array.buffer === root.directory &&
|
|
2148
|
+
array.byteOffset === identity &&
|
|
2149
|
+
expected === packedControl(2, 4) &&
|
|
2150
|
+
replacement === 0n
|
|
2151
|
+
) {
|
|
2152
|
+
stopped = true;
|
|
2153
|
+
throw interrupted;
|
|
2154
|
+
}
|
|
2155
|
+
return value;
|
|
2156
|
+
}) as typeof Atomics.compareExchange;
|
|
2157
|
+
try {
|
|
2158
|
+
expect(() => collectDirectoryJob(root.directory, jobSlot, 2)).toThrow(interrupted);
|
|
2159
|
+
} finally {
|
|
2160
|
+
Atomics.compareExchange = original;
|
|
2161
|
+
}
|
|
2162
|
+
helpDirectoryJobs(root.directory);
|
|
2163
|
+
expect(stopped).toBe(true);
|
|
2164
|
+
expect(directorySlots(root.directory)).toHaveLength(2);
|
|
2165
|
+
expect(controlLoad(workerProcessState(descendant).controlParent)).toBe(1);
|
|
2166
|
+
expect(controlLoad(workerProcessState(descendant).jobControlParent)).toBe(1);
|
|
2167
|
+
});
|
|
2168
|
+
|
|
2169
|
+
test("an internal readiness SRCH race cannot skip physical termination or orphan collection", async () => {
|
|
2170
|
+
let terminated = 0;
|
|
2171
|
+
const f = fixture({
|
|
2172
|
+
capacity: 3,
|
|
2173
|
+
terminate() {
|
|
2174
|
+
terminated++;
|
|
2175
|
+
},
|
|
2176
|
+
beforeActivation(supervisor) {
|
|
2177
|
+
supervisor.registerJobReadiness(() => {
|
|
2178
|
+
throw new ProcessError(ProcessErrno.SRCH, "captured job header was recycled");
|
|
2179
|
+
});
|
|
2180
|
+
},
|
|
2181
|
+
});
|
|
2182
|
+
const parent = f.root.spawn(1, request());
|
|
2183
|
+
await f.flush();
|
|
2184
|
+
await f.supervisor.start(parent);
|
|
2185
|
+
const client = f.client(f.broker.get(parent)!);
|
|
2186
|
+
const child = client.spawn(parent, request());
|
|
2187
|
+
await f.flush();
|
|
2188
|
+
await f.supervisor.start(child);
|
|
2189
|
+
expect(() => f.supervisor.exit(child, 3)).not.toThrow();
|
|
2190
|
+
expect(f.supervisor.get(child)?.result?.code).toBe(3);
|
|
2191
|
+
expect(() => f.supervisor.exit(parent, 4)).not.toThrow();
|
|
2192
|
+
expect(terminated).toBe(2);
|
|
2193
|
+
expect(f.supervisor.get(child)).toBeUndefined();
|
|
2194
|
+
});
|
|
2195
|
+
|
|
2196
|
+
test("host collective signaling ignores collection between its retained-record check and outcome snapshot", async () => {
|
|
2197
|
+
const f = fixture({ capacity: 3 });
|
|
2198
|
+
const leader = f.root.spawn(1, request());
|
|
2199
|
+
await f.flush();
|
|
2200
|
+
const job = f.root.jobOf(leader);
|
|
2201
|
+
const member = f.root.spawn(1, request({ job }));
|
|
2202
|
+
await f.flush();
|
|
2203
|
+
const transport = f.broker.get(member)!,
|
|
2204
|
+
state = workerProcessState(transport);
|
|
2205
|
+
f.supervisor.onChildExit((event) => {
|
|
2206
|
+
if (event.pid === leader) f.supervisor.exit(member, 4);
|
|
2207
|
+
});
|
|
2208
|
+
const original = Atomics.load;
|
|
2209
|
+
let raced = false;
|
|
2210
|
+
Atomics.load = ((array: BigInt64Array, index: number) => {
|
|
2211
|
+
const value = original(array, index);
|
|
2212
|
+
if (
|
|
2213
|
+
!raced &&
|
|
2214
|
+
array instanceof BigInt64Array &&
|
|
2215
|
+
array.buffer.byteLength === state.signals.outcome.buffer.byteLength &&
|
|
2216
|
+
array.byteOffset === state.signals.outcome.byteOffset &&
|
|
2217
|
+
index === 0 &&
|
|
2218
|
+
f.supervisor.get(member)?.result &&
|
|
2219
|
+
controlLoad(state.jobConfirmed) === 1
|
|
2220
|
+
) {
|
|
2221
|
+
raced = true;
|
|
2222
|
+
collectDirectoryProcess(transport);
|
|
2223
|
+
}
|
|
2224
|
+
return value;
|
|
2225
|
+
}) as typeof Atomics.load;
|
|
2226
|
+
try {
|
|
2227
|
+
expect(() => f.supervisor.killJob(job, 15)).not.toThrow();
|
|
2228
|
+
} finally {
|
|
2229
|
+
Atomics.load = original;
|
|
2230
|
+
}
|
|
2231
|
+
expect(raced).toBe(true);
|
|
2232
|
+
expect(f.supervisor.get(leader)?.result?.status).toBe(143);
|
|
2233
|
+
expect(f.supervisor.get(member)?.result?.status).toBe(143);
|
|
2234
|
+
f.broker.pump();
|
|
2235
|
+
expect(f.supervisor.get(member)).toBeUndefined();
|
|
2236
|
+
});
|
|
2237
|
+
|
|
2238
|
+
test("supervisor disposal skips unacknowledged collected records and still stops live members", async () => {
|
|
2239
|
+
let terminated = 0;
|
|
2240
|
+
const f = fixture({
|
|
2241
|
+
capacity: 3,
|
|
2242
|
+
terminate() {
|
|
2243
|
+
terminated++;
|
|
2244
|
+
},
|
|
2245
|
+
});
|
|
2246
|
+
const old = f.root.spawn(1, request());
|
|
2247
|
+
await f.flush();
|
|
2248
|
+
await f.supervisor.start(old);
|
|
2249
|
+
const oldState = workerProcessState(f.broker.get(old)!);
|
|
2250
|
+
const { fd, counts } = f.source(f.root.options.descriptors);
|
|
2251
|
+
const live = f.root.spawn(1, request({ fds: [{ child: 1, parent: fd }] }));
|
|
2252
|
+
f.root.options.descriptors.close(fd);
|
|
2253
|
+
await f.flush();
|
|
2254
|
+
await f.supervisor.start(live);
|
|
2255
|
+
f.supervisor.exit(old, 21);
|
|
2256
|
+
const silent = new WorkerProcessClient({ ...f.root.options, postMessage() {} });
|
|
2257
|
+
expect(silent.waitJob(1, oldState.job)?.code).toBe(21);
|
|
2258
|
+
expect(() => readOutcome(oldState.signals.outcome)).toThrow("collected");
|
|
2259
|
+
expect(f.supervisor.get(old)?.result?.code).toBe(21); // No host receipt or pump yet.
|
|
2260
|
+
expect(counts[0]).toBe(1);
|
|
2261
|
+
expect(() => f.supervisor.dispose()).not.toThrow();
|
|
2262
|
+
expect(terminated).toBe(2);
|
|
2263
|
+
expect(counts[0]).toBe(0);
|
|
2264
|
+
expect(Array.from(f.supervisor.table.values())).toEqual([]);
|
|
2265
|
+
expect(Array.from(f.supervisor.table.jobValues())).toEqual([]);
|
|
2266
|
+
});
|
|
2267
|
+
|
|
2268
|
+
test("an unposted failed spawn releases its job when parent death auto-collects its process", () => {
|
|
2269
|
+
const transport = createWorkerProcessTransport({ capacity: 2 });
|
|
2270
|
+
const descriptors = new DescriptorTable();
|
|
2271
|
+
cleanups.push(() => descriptors.dispose());
|
|
2272
|
+
const { codec, source } = fakeCodec();
|
|
2273
|
+
const { fd, counts } = source(descriptors, "directory");
|
|
2274
|
+
const root = workerProcessState(transport);
|
|
2275
|
+
const failure = new Error("source revoked during export");
|
|
2276
|
+
let held = false,
|
|
2277
|
+
cancelled = 0,
|
|
2278
|
+
released = 0,
|
|
2279
|
+
posted = 0;
|
|
2280
|
+
const client = new WorkerProcessClient({
|
|
2281
|
+
transport,
|
|
2282
|
+
descriptors,
|
|
2283
|
+
codec: {
|
|
2284
|
+
...codec,
|
|
2285
|
+
export() {
|
|
2286
|
+
expect(held).toBe(true);
|
|
2287
|
+
claimOutcome(root.signals.outcome, { kind: "signaled", code: 9 });
|
|
2288
|
+
throw failure;
|
|
2289
|
+
},
|
|
2290
|
+
},
|
|
2291
|
+
postMessage() {
|
|
2292
|
+
posted++;
|
|
2293
|
+
},
|
|
2294
|
+
prepareSpawn() {
|
|
2295
|
+
held = true;
|
|
2296
|
+
return {
|
|
2297
|
+
cancel() {
|
|
2298
|
+
expect(held).toBe(true);
|
|
2299
|
+
cancelled++;
|
|
2300
|
+
},
|
|
2301
|
+
release() {
|
|
2302
|
+
expect(held).toBe(true);
|
|
2303
|
+
released++;
|
|
2304
|
+
held = false;
|
|
2305
|
+
},
|
|
2306
|
+
};
|
|
2307
|
+
},
|
|
2308
|
+
});
|
|
2309
|
+
let caught: unknown;
|
|
2310
|
+
try {
|
|
2311
|
+
client.spawn(root.pid, request({ fds: [{ child: 3, parent: fd }] }));
|
|
2312
|
+
} catch (error) {
|
|
2313
|
+
caught = error;
|
|
2314
|
+
}
|
|
2315
|
+
expect(caught).toMatchObject({ message: failure.message, errno: 29 });
|
|
2316
|
+
expect({ held, cancelled, released, posted }).toEqual({
|
|
2317
|
+
held: false,
|
|
2318
|
+
cancelled: 1,
|
|
2319
|
+
released: 1,
|
|
2320
|
+
posted: 0,
|
|
2321
|
+
});
|
|
2322
|
+
expect(counts[0]).toBe(1);
|
|
2323
|
+
expect(directorySlots(transport.directory)).toEqual([0]);
|
|
2324
|
+
expect(directoryJobs(transport.directory)).toEqual([root.jobSlot]);
|
|
2325
|
+
helpDirectoryJobs(transport.directory);
|
|
2326
|
+
expect(directoryJobs(transport.directory)).toEqual([root.jobSlot]);
|
|
2327
|
+
// The remaining allocator capacity can admit another independent process/job;
|
|
2328
|
+
// no inaccessible zero-pending job occupies the second row after failed export.
|
|
2329
|
+
const next = { ...transport, ...reserveDirectoryProcess(transport, 3, root.pid, 3, root.pid) };
|
|
2330
|
+
const nextState = workerProcessState(next);
|
|
2331
|
+
expect(nextState.job).toBe(3);
|
|
2332
|
+
expect(directorySlots(transport.directory)).toHaveLength(2);
|
|
2333
|
+
expect(directoryJobs(transport.directory)).toHaveLength(2);
|
|
2334
|
+
claimOutcome(nextState.signals.outcome, { kind: "exited", code: 0 });
|
|
2335
|
+
confirmWorkerProcessJob(next); // Dead parent's safe child is automatically collected.
|
|
2336
|
+
collectDirectoryJob(transport.directory, nextState.jobSlot, nextState.job);
|
|
2337
|
+
confirmWorkerProcessJob(transport);
|
|
2338
|
+
collectDirectoryJob(transport.directory, root.jobSlot, root.job);
|
|
2339
|
+
expect(directorySlots(transport.directory)).toEqual([]);
|
|
2340
|
+
expect(directoryJobs(transport.directory)).toEqual([]);
|
|
2341
|
+
});
|
|
2342
|
+
|
|
2343
|
+
test("failed spawn cleanup cannot collect a job reused during admission-fence release", () => {
|
|
2344
|
+
const transport = createWorkerProcessTransport({ capacity: 2 });
|
|
2345
|
+
const descriptors = new DescriptorTable();
|
|
2346
|
+
cleanups.push(() => descriptors.dispose());
|
|
2347
|
+
const { codec, source } = fakeCodec(),
|
|
2348
|
+
{ fd } = source(descriptors, "directory");
|
|
2349
|
+
const root = workerProcessState(transport);
|
|
2350
|
+
const failure = new Error("revoked export");
|
|
2351
|
+
let replacement!: WorkerProcessTransport;
|
|
2352
|
+
const client = new WorkerProcessClient({
|
|
2353
|
+
transport,
|
|
2354
|
+
descriptors,
|
|
2355
|
+
codec: {
|
|
2356
|
+
...codec,
|
|
2357
|
+
export() {
|
|
2358
|
+
claimOutcome(root.signals.outcome, { kind: "signaled", code: 9 });
|
|
2359
|
+
throw failure;
|
|
2360
|
+
},
|
|
2361
|
+
},
|
|
2362
|
+
postMessage() {
|
|
2363
|
+
throw new Error("must not publish");
|
|
2364
|
+
},
|
|
2365
|
+
prepareSpawn() {
|
|
2366
|
+
return {
|
|
2367
|
+
release() {
|
|
2368
|
+
const failedJob = findDirectoryJob(transport.directory, 2)!;
|
|
2369
|
+
expect(readOutcome(failedJob.outcome)).toMatchObject({ kind: "start-failed", code: 5 });
|
|
2370
|
+
collectDirectoryJob(transport.directory, failedJob.slot, failedJob.id);
|
|
2371
|
+
replacement = {
|
|
2372
|
+
...transport,
|
|
2373
|
+
...reserveDirectoryProcess(transport, 3, root.pid, 3, root.pid),
|
|
2374
|
+
};
|
|
2375
|
+
expect(workerProcessState(replacement).jobSlot).toBe(failedJob.slot);
|
|
2376
|
+
},
|
|
2377
|
+
};
|
|
2378
|
+
},
|
|
2379
|
+
});
|
|
2380
|
+
let caught: unknown;
|
|
2381
|
+
try {
|
|
2382
|
+
client.spawn(root.pid, request({ fds: [{ child: 3, parent: fd }] }));
|
|
2383
|
+
} catch (error) {
|
|
2384
|
+
caught = error;
|
|
2385
|
+
}
|
|
2386
|
+
expect(caught).toMatchObject({ message: failure.message, errno: 29 });
|
|
2387
|
+
const state = workerProcessState(replacement);
|
|
2388
|
+
expect(state.job).toBe(3);
|
|
2389
|
+
expect(readOutcome(state.signals.outcome)).toBeNull();
|
|
2390
|
+
expect(controlLoad(state.jobPending)).toBe(1);
|
|
2391
|
+
claimOutcome(state.signals.outcome, { kind: "exited", code: 0 });
|
|
2392
|
+
confirmWorkerProcessJob(replacement);
|
|
2393
|
+
collectDirectoryJob(transport.directory, state.jobSlot, state.job);
|
|
2394
|
+
confirmWorkerProcessJob(transport);
|
|
2395
|
+
collectDirectoryJob(transport.directory, root.jobSlot, root.job);
|
|
2396
|
+
expect(directorySlots(transport.directory)).toEqual([]);
|
|
2397
|
+
expect(directoryJobs(transport.directory)).toEqual([]);
|
|
2398
|
+
});
|
|
2399
|
+
|
|
2400
|
+
test("a new job stays private when its leader's full process-slot scan races a public join", () => {
|
|
2401
|
+
const root = createWorkerProcessTransport({ capacity: 3 });
|
|
2402
|
+
const messages: WorkerProcessMessage[] = [];
|
|
2403
|
+
const { codec } = fakeCodec();
|
|
2404
|
+
const make = (transport: WorkerProcessTransport) => {
|
|
2405
|
+
const descriptors = new DescriptorTable();
|
|
2406
|
+
cleanups.push(() => descriptors.dispose());
|
|
2407
|
+
return new WorkerProcessClient({
|
|
2408
|
+
transport,
|
|
2409
|
+
descriptors,
|
|
2410
|
+
codec,
|
|
2411
|
+
postMessage(message) {
|
|
2412
|
+
messages.push(message);
|
|
2413
|
+
},
|
|
2414
|
+
});
|
|
2415
|
+
};
|
|
2416
|
+
const a = make(root);
|
|
2417
|
+
const parentPid = a.spawn(1, request({ job: a.job })),
|
|
2418
|
+
parent = messages.at(-1)!.transport;
|
|
2419
|
+
a.spawn(1, request({ job: a.job }));
|
|
2420
|
+
const filler = messages.at(-1)!.transport,
|
|
2421
|
+
b = make(parent);
|
|
2422
|
+
readyForCollection(filler);
|
|
2423
|
+
const original = Atomics.compareExchange;
|
|
2424
|
+
let raced = false,
|
|
2425
|
+
joinError: unknown;
|
|
2426
|
+
const offset = workerProcessState(filler).signals.outcome.byteOffset - 5 * 8;
|
|
2427
|
+
Atomics.compareExchange = ((
|
|
2428
|
+
array: BigInt64Array,
|
|
2429
|
+
index: number,
|
|
2430
|
+
expected: bigint,
|
|
2431
|
+
replacement: bigint,
|
|
2432
|
+
) => {
|
|
2433
|
+
const previous = original(array, index, expected, replacement);
|
|
2434
|
+
if (
|
|
2435
|
+
!raced &&
|
|
2436
|
+
array instanceof BigInt64Array &&
|
|
2437
|
+
array.buffer === root.directory &&
|
|
2438
|
+
array.byteOffset === offset &&
|
|
2439
|
+
index === 0 &&
|
|
2440
|
+
expected === 0n &&
|
|
2441
|
+
replacement === packedControl(4, 2)
|
|
2442
|
+
) {
|
|
2443
|
+
raced = true;
|
|
2444
|
+
collectDirectoryProcess(filler);
|
|
2445
|
+
try {
|
|
2446
|
+
b.spawn(parentPid, request({ job: 2 }));
|
|
2447
|
+
} catch (error) {
|
|
2448
|
+
joinError = error;
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
return previous;
|
|
2452
|
+
}) as typeof Atomics.compareExchange;
|
|
2453
|
+
try {
|
|
2454
|
+
expectErrno(() => a.spawn(1, request()), ProcessErrno.AGAIN);
|
|
2455
|
+
} finally {
|
|
2456
|
+
Atomics.compareExchange = original;
|
|
2457
|
+
}
|
|
2458
|
+
expect(raced).toBe(true);
|
|
2459
|
+
expect(joinError).toMatchObject({ name: "ProcessError", errno: ProcessErrno.CHILD });
|
|
2460
|
+
expect(messages).toHaveLength(2); // Neither the failed creator nor racing join published.
|
|
2461
|
+
expect(Array.from(directoryProcesses(root.directory), (state) => state.pid)).toEqual([
|
|
2462
|
+
1,
|
|
2463
|
+
parentPid,
|
|
2464
|
+
]);
|
|
2465
|
+
expect(directoryJobs(root.directory)).toEqual([0]);
|
|
2466
|
+
helpDirectoryJobs(root.directory);
|
|
2467
|
+
expect(directoryJobs(root.directory)).toEqual([0]);
|
|
2468
|
+
const nextPid = b.spawn(parentPid, request()),
|
|
2469
|
+
next = messages.at(-1)!.transport;
|
|
2470
|
+
const nextState = workerProcessState(next);
|
|
2471
|
+
expect(nextState.pid).toBe(nextPid);
|
|
2472
|
+
expect(nextState.jobLeaderPid).toBe(nextPid);
|
|
2473
|
+
expect(nextState.jobOwner).toBe(parentPid);
|
|
2474
|
+
expect(readOutcome(nextState.jobOutcome)).toBeNull();
|
|
2475
|
+
expect(directorySlots(root.directory)).toHaveLength(3);
|
|
2476
|
+
expect(directoryJobs(root.directory)).toHaveLength(2);
|
|
2477
|
+
readyForCollection(next);
|
|
2478
|
+
expect(a.waitJob(1, nextState.job)?.code).toBe(0);
|
|
2479
|
+
readyForCollection(parent);
|
|
2480
|
+
collectDirectoryProcess(parent);
|
|
2481
|
+
const rootState = workerProcessState(root);
|
|
2482
|
+
readyForCollection(root);
|
|
2483
|
+
collectDirectoryJob(root.directory, rootState.jobSlot, rootState.job);
|
|
2484
|
+
expect(directorySlots(root.directory)).toEqual([]);
|
|
2485
|
+
expect(directoryJobs(root.directory)).toEqual([]);
|
|
2486
|
+
});
|
|
2487
|
+
|
|
2488
|
+
test("a successfully published new job is joinable with its original leader and typed outcome", async () => {
|
|
2489
|
+
const f = fixture({ capacity: 3 });
|
|
2490
|
+
const leader = f.root.spawn(1, request());
|
|
2491
|
+
await f.flush();
|
|
2492
|
+
const job = f.root.jobOf(leader);
|
|
2493
|
+
const member = f.root.spawn(1, request({ job }));
|
|
2494
|
+
await f.flush();
|
|
2495
|
+
expect(workerProcessState(f.broker.get(member)!)).toMatchObject({
|
|
2496
|
+
job,
|
|
2497
|
+
jobLeaderPid: leader,
|
|
2498
|
+
jobOwner: 1,
|
|
2499
|
+
});
|
|
2500
|
+
f.supervisor.exit(leader, 27);
|
|
2501
|
+
f.supervisor.exit(member, 4);
|
|
2502
|
+
expect(f.root.waitJob(1, job)?.code).toBe(27);
|
|
2503
|
+
await f.flush();
|
|
2504
|
+
expect(directorySlots(f.transport.directory)).toEqual([0]);
|
|
2505
|
+
expect(directoryJobs(f.transport.directory)).toEqual([0]);
|
|
2506
|
+
});
|
|
2507
|
+
|
|
2508
|
+
for (const joining of [false, true]) {
|
|
2509
|
+
test(`process initialization failure rolls back ${joining ? "joined membership" : "private job"} and its captured process reservation`, () => {
|
|
2510
|
+
const root = createWorkerProcessTransport({ capacity: 2 });
|
|
2511
|
+
const rootState = workerProcessState(root);
|
|
2512
|
+
const processStride = (rootState.jobOutcome.byteOffset - 32 - 3 * 8) / 2;
|
|
2513
|
+
const original = Atomics.store;
|
|
2514
|
+
const failure = new Error("initialization interrupted");
|
|
2515
|
+
let interrupted = false;
|
|
2516
|
+
Atomics.store = ((array: BigInt64Array, index: number, value: bigint) => {
|
|
2517
|
+
if (
|
|
2518
|
+
!interrupted &&
|
|
2519
|
+
array instanceof BigInt64Array &&
|
|
2520
|
+
array.buffer === root.directory &&
|
|
2521
|
+
array.byteOffset === 32 + processStride &&
|
|
2522
|
+
index === 1 &&
|
|
2523
|
+
value === packedControl(2, 1)
|
|
2524
|
+
) {
|
|
2525
|
+
interrupted = true;
|
|
2526
|
+
throw failure;
|
|
2527
|
+
}
|
|
2528
|
+
return original(array, index, value);
|
|
2529
|
+
}) as typeof Atomics.store;
|
|
2530
|
+
try {
|
|
2531
|
+
expect(() =>
|
|
2532
|
+
reserveDirectoryProcess(
|
|
2533
|
+
root,
|
|
2534
|
+
2,
|
|
2535
|
+
1,
|
|
2536
|
+
joining ? rootState.job : 2,
|
|
2537
|
+
1,
|
|
2538
|
+
joining ? rootState.jobSlot : undefined,
|
|
2539
|
+
),
|
|
2540
|
+
).toThrow(failure);
|
|
2541
|
+
} finally {
|
|
2542
|
+
Atomics.store = original;
|
|
2543
|
+
}
|
|
2544
|
+
expect(interrupted).toBe(true);
|
|
2545
|
+
expect(directorySlots(root.directory)).toEqual([0]);
|
|
2546
|
+
expect(directoryJobs(root.directory)).toEqual([0]);
|
|
2547
|
+
expect(controlLoad(rootState.jobPending)).toBe(1);
|
|
2548
|
+
const next = { ...root, ...reserveDirectoryProcess(root, 3, 1, 3, 1) };
|
|
2549
|
+
const state = workerProcessState(next);
|
|
2550
|
+
expect(state.pid).toBe(3);
|
|
2551
|
+
readyForCollection(next);
|
|
2552
|
+
collectDirectoryJob(root.directory, state.jobSlot, state.job);
|
|
2553
|
+
readyForCollection(root);
|
|
2554
|
+
collectDirectoryJob(root.directory, rootState.jobSlot, rootState.job);
|
|
2555
|
+
expect(directorySlots(root.directory)).toEqual([]);
|
|
2556
|
+
expect(directoryJobs(root.directory)).toEqual([]);
|
|
2557
|
+
});
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
for (const completion of ["exit", "kill"] as const) {
|
|
2561
|
+
test(`worker wait collects direct child but wait_job retains a live grandchild until ${completion}`, async () => {
|
|
2562
|
+
const f = fixture({ capacity: 3 });
|
|
2563
|
+
const memory = new WebAssembly.Memory({ initial: 1 });
|
|
2564
|
+
const abi = new ProcessABI({
|
|
2565
|
+
processIdentity: f.root.processIdentity,
|
|
2566
|
+
memory,
|
|
2567
|
+
descriptors: f.root.options.descriptors,
|
|
2568
|
+
fs: new MemFS(),
|
|
2569
|
+
pid: f.root.pid,
|
|
2570
|
+
service: f.root,
|
|
2571
|
+
signals: f.root.signals,
|
|
2572
|
+
});
|
|
2573
|
+
const view = new DataView(memory.buffer);
|
|
2574
|
+
const leaderPid = f.root.spawn(f.root.pid, request());
|
|
2575
|
+
await f.flush();
|
|
2576
|
+
const job = f.root.jobOf(leaderPid),
|
|
2577
|
+
leader = f.client(f.broker.get(leaderPid)!);
|
|
2578
|
+
const grandchildPid = leader.spawn(leaderPid, request({ job }));
|
|
2579
|
+
await f.flush();
|
|
2580
|
+
const grandchild = f.client(f.broker.get(grandchildPid)!);
|
|
2581
|
+
expect(abi.imports.wait!(leaderPid, 64)).toBe(-6);
|
|
2582
|
+
leader.exit(23);
|
|
2583
|
+
await f.flush();
|
|
2584
|
+
// Exactly bash-web's order: collect direct children first, then wait on their group.
|
|
2585
|
+
expect(abi.imports.wait!(leaderPid, 64)).toBe(0);
|
|
2586
|
+
expect(view.getInt32(68, true)).toBe(23);
|
|
2587
|
+
expect(abi.imports.wait!(leaderPid, 64)).toBe(-12);
|
|
2588
|
+
await f.flush();
|
|
2589
|
+
expect(directorySlots(f.transport.directory)).toHaveLength(2);
|
|
2590
|
+
expect(f.supervisor.get(leaderPid)).toBeUndefined();
|
|
2591
|
+
for (let repeat = 0; repeat < 3; repeat++) expect(abi.imports.wait_job!(job, 1, 80)).toBe(-6);
|
|
2592
|
+
// The orphan remains controllable even though its original parent's slot is gone.
|
|
2593
|
+
if (completion === "kill") f.root.kill(grandchildPid, 9);
|
|
2594
|
+
else grandchild.exit(7);
|
|
2595
|
+
await f.flush();
|
|
2596
|
+
expect(abi.imports.wait_job!(job, 1, 80)).toBe(0);
|
|
2597
|
+
expect(view.getInt32(84, true)).toBe(23);
|
|
2598
|
+
expect(abi.imports.wait_job!(job, 1, 80)).toBe(-12);
|
|
2599
|
+
await f.flush();
|
|
2600
|
+
expect(directorySlots(f.transport.directory)).toHaveLength(1);
|
|
2601
|
+
expect(directoryJobs(f.transport.directory)).toHaveLength(1);
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
test("worker child polling is observational and the consuming wait releases capacity before its receipt", async () => {
|
|
2606
|
+
const f = fixture({ capacity: 2 });
|
|
2607
|
+
const memory = new WebAssembly.Memory({ initial: 1 });
|
|
2608
|
+
const abi = new ProcessABI({
|
|
2609
|
+
processIdentity: f.root.processIdentity,
|
|
2610
|
+
memory,
|
|
2611
|
+
descriptors: f.root.options.descriptors,
|
|
2612
|
+
fs: new MemFS(),
|
|
2613
|
+
pid: f.root.pid,
|
|
2614
|
+
service: f.root,
|
|
2615
|
+
signals: f.root.signals,
|
|
2616
|
+
});
|
|
2617
|
+
const pid = f.root.spawn(f.root.pid, request({ job: f.root.job }));
|
|
2618
|
+
await f.flush();
|
|
2619
|
+
const view = new DataView(memory.buffer);
|
|
2620
|
+
view.setUint32(256, 2, true);
|
|
2621
|
+
view.setUint32(260, pid, true);
|
|
2622
|
+
f.supervisor.exit(pid, 31);
|
|
2623
|
+
for (let repeat = 0; repeat < 3; repeat++) {
|
|
2624
|
+
expect(abi.imports.poll!(256, 1, 0, 512)).toBe(1);
|
|
2625
|
+
expect(directorySlots(f.transport.directory)).toHaveLength(2);
|
|
2626
|
+
}
|
|
2627
|
+
expect(abi.imports.wait!(pid, 64)).toBe(0);
|
|
2628
|
+
expect(view.getInt32(68, true)).toBe(31);
|
|
2629
|
+
expect(abi.imports.wait!(pid, 64)).toBe(-12);
|
|
2630
|
+
expect(abi.imports.poll!(256, 1, 0, 512)).toBe(-12);
|
|
2631
|
+
const next = f.root.spawn(f.root.pid, request({ job: f.root.job }));
|
|
2632
|
+
expect(next).toBeGreaterThan(pid);
|
|
2633
|
+
await f.flush();
|
|
2634
|
+
expect(f.supervisor.get(pid)).toBeUndefined();
|
|
2635
|
+
expect(f.supervisor.get(next)).toBeDefined();
|
|
2636
|
+
});
|
|
2637
|
+
|
|
2638
|
+
test("failed executable spawns release their slots through individual waits beyond directory capacity", async () => {
|
|
2639
|
+
const f = fixture({ capacity: 2 });
|
|
2640
|
+
for (let iteration = 0; iteration < 32; iteration++) {
|
|
2641
|
+
const pid = f.root.spawn(f.root.pid, request({ executable: "missing", job: f.root.job }));
|
|
2642
|
+
await f.flush();
|
|
2643
|
+
await f.supervisor.start(pid);
|
|
2644
|
+
expect(f.root.wait(f.root.pid, pid)).toMatchObject({ kind: "start-failed", error: "ENOENT" });
|
|
2645
|
+
expect(directorySlots(f.transport.directory)).toHaveLength(1);
|
|
2646
|
+
await f.flush();
|
|
2647
|
+
expect(f.supervisor.get(pid)).toBeUndefined();
|
|
2648
|
+
expect(f.broker.get(pid)).toBeUndefined();
|
|
2649
|
+
}
|
|
2650
|
+
});
|
|
2651
|
+
|
|
2652
|
+
for (const [error, name, code] of [
|
|
2653
|
+
[new RangeError("codec allocation"), "ENOMEM", 12],
|
|
2654
|
+
[new Error("codec failed"), "EIO", 5],
|
|
2655
|
+
] as const) {
|
|
2656
|
+
test(`codec construction failure publishes ${name} and waits for its host cleanup fence`, async () => {
|
|
2657
|
+
const transport = createWorkerProcessTransport(),
|
|
2658
|
+
descriptors = new DescriptorTable();
|
|
2659
|
+
const messages: WorkerProcessMessage[] = [];
|
|
2660
|
+
const codec: WorkerDescriptorCodec = {
|
|
2661
|
+
export() {},
|
|
2662
|
+
import() {
|
|
2663
|
+
throw new Error("unused");
|
|
2664
|
+
},
|
|
2665
|
+
discard() {},
|
|
2666
|
+
};
|
|
2667
|
+
const client = new WorkerProcessClient({
|
|
2668
|
+
transport,
|
|
2669
|
+
descriptors,
|
|
2670
|
+
codec,
|
|
2671
|
+
postMessage(message) {
|
|
2672
|
+
messages.push(message);
|
|
2673
|
+
},
|
|
2674
|
+
});
|
|
2675
|
+
const pid = client.spawn(client.pid, request()),
|
|
2676
|
+
child = messages[0]!.transport,
|
|
2677
|
+
state = workerProcessState(child),
|
|
2678
|
+
job = state.job;
|
|
2679
|
+
let enter!: () => void, release!: () => void;
|
|
2680
|
+
const entered = new Promise<void>((resolve) => {
|
|
2681
|
+
enter = resolve;
|
|
2682
|
+
}),
|
|
2683
|
+
fence = new Promise<void>((resolve) => {
|
|
2684
|
+
release = resolve;
|
|
2685
|
+
});
|
|
2686
|
+
const broker = new WorkerProcessBroker({
|
|
2687
|
+
supervisor() {
|
|
2688
|
+
throw new Error("must not activate");
|
|
2689
|
+
},
|
|
2690
|
+
codec() {
|
|
2691
|
+
throw error;
|
|
2692
|
+
},
|
|
2693
|
+
quiesce() {
|
|
2694
|
+
enter();
|
|
2695
|
+
return fence;
|
|
2696
|
+
},
|
|
2697
|
+
});
|
|
2698
|
+
broker.adoptRoot(transport);
|
|
2699
|
+
try {
|
|
2700
|
+
const pending = broker.handle(messages[0]!).catch((value) => value);
|
|
2701
|
+
await entered;
|
|
2702
|
+
expect(readOutcome(state.signals.outcome)).toEqual({
|
|
2703
|
+
kind: "start-failed",
|
|
2704
|
+
error: name,
|
|
2705
|
+
code,
|
|
2706
|
+
status: null,
|
|
2707
|
+
});
|
|
2708
|
+
expect(client.wait(client.pid, pid)).toBeNull();
|
|
2709
|
+
release();
|
|
2710
|
+
expect(await pending).toBe(error);
|
|
2711
|
+
expect(client.wait(client.pid, pid)).toMatchObject({ kind: "start-failed", error: name });
|
|
2712
|
+
expect(client.waitJob(client.pid, job)).toMatchObject({ kind: "start-failed", error: name });
|
|
2713
|
+
} finally {
|
|
2714
|
+
release();
|
|
2715
|
+
broker.dispose();
|
|
2716
|
+
descriptors.dispose();
|
|
2717
|
+
}
|
|
2718
|
+
});
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
for (const phase of ["before disposal", "after disposal", "failed fence"] as const) {
|
|
2722
|
+
test(`rejected retained tokens confirm only after release and a successful fence ${phase}`, async () => {
|
|
2723
|
+
const transport = createWorkerProcessTransport(),
|
|
2724
|
+
descriptors = new DescriptorTable();
|
|
2725
|
+
const messages: WorkerProcessMessage[] = [],
|
|
2726
|
+
errors: unknown[] = [];
|
|
2727
|
+
const { codec, source } = fakeCodec();
|
|
2728
|
+
const inherited = source(descriptors);
|
|
2729
|
+
const client = new WorkerProcessClient({
|
|
2730
|
+
transport,
|
|
2731
|
+
descriptors,
|
|
2732
|
+
codec,
|
|
2733
|
+
postMessage(message) {
|
|
2734
|
+
messages.push(message);
|
|
2735
|
+
},
|
|
2736
|
+
});
|
|
2737
|
+
const pid = client.spawn(client.pid, request({ fds: [{ child: 3, parent: inherited.fd }] }));
|
|
2738
|
+
const child = messages[0]!.transport,
|
|
2739
|
+
state = workerProcessState(child),
|
|
2740
|
+
job = state.job;
|
|
2741
|
+
let recover = false,
|
|
2742
|
+
release!: () => void,
|
|
2743
|
+
entered!: () => void;
|
|
2744
|
+
const fence = new Promise<void>((resolve) => {
|
|
2745
|
+
release = resolve;
|
|
2746
|
+
}),
|
|
2747
|
+
started = new Promise<void>((resolve) => {
|
|
2748
|
+
entered = resolve;
|
|
2749
|
+
});
|
|
2750
|
+
const broker = new WorkerProcessBroker({
|
|
2751
|
+
supervisor() {
|
|
2752
|
+
throw new Error("must not activate");
|
|
2753
|
+
},
|
|
2754
|
+
codec() {
|
|
2755
|
+
if (!recover) throw new RangeError("codec allocation");
|
|
2756
|
+
return codec;
|
|
2757
|
+
},
|
|
2758
|
+
quiesce() {
|
|
2759
|
+
entered();
|
|
2760
|
+
return phase === "failed fence" ? Promise.reject(new Error("failed fence")) : fence;
|
|
2761
|
+
},
|
|
2762
|
+
onError(error) {
|
|
2763
|
+
errors.push(error);
|
|
2764
|
+
},
|
|
2765
|
+
});
|
|
2766
|
+
broker.adoptRoot(transport);
|
|
2767
|
+
try {
|
|
2768
|
+
const pending = broker.handle(messages[0]!).catch((error) => error);
|
|
2769
|
+
await started;
|
|
2770
|
+
expect(client.wait(client.pid, pid)).toBeNull();
|
|
2771
|
+
expect(inherited.counts[0]).toBe(2);
|
|
2772
|
+
if (phase === "before disposal") {
|
|
2773
|
+
release();
|
|
2774
|
+
await pending;
|
|
2775
|
+
}
|
|
2776
|
+
if (phase === "failed fence") await pending;
|
|
2777
|
+
recover = true;
|
|
2778
|
+
broker.dispose();
|
|
2779
|
+
expect(inherited.counts[0]).toBe(1);
|
|
2780
|
+
if (phase === "after disposal") {
|
|
2781
|
+
expect(client.wait(client.pid, pid)).toBeNull();
|
|
2782
|
+
release();
|
|
2783
|
+
await pending;
|
|
2784
|
+
}
|
|
2785
|
+
if (phase === "failed fence") expect(client.wait(client.pid, pid)).toBeNull();
|
|
2786
|
+
else {
|
|
2787
|
+
// Disposal killed the parent, so safe confirmation also retires its orphan child.
|
|
2788
|
+
expectErrno(() => client.wait(client.pid, pid), ProcessErrno.CHILD);
|
|
2789
|
+
expect(directorySlots(child.directory)).not.toContain(child.slot);
|
|
2790
|
+
const group = directoryJob(child.directory, state.jobSlot, job);
|
|
2791
|
+
expect(controlLoad(group.pending)).toBe(0);
|
|
2792
|
+
expect(readOutcome(group.outcome)).toMatchObject({ kind: "start-failed", error: "ENOMEM" });
|
|
2793
|
+
collectDirectoryJob(child.directory, group.slot, job);
|
|
2794
|
+
}
|
|
2795
|
+
expect(errors.length).toBeGreaterThan(0);
|
|
2796
|
+
} finally {
|
|
2797
|
+
release();
|
|
2798
|
+
broker.dispose();
|
|
2799
|
+
descriptors.dispose();
|
|
2800
|
+
}
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
for (const ordering of ["before-claim", "after-claim", "helper-header"] as const)
|
|
2805
|
+
for (const recycle of [false, true]) {
|
|
2806
|
+
test(`wait_job preserves its claim result when a helper retires ${ordering}${recycle ? " and recycles the slot" : ""}`, async () => {
|
|
2807
|
+
const f = fixture({ capacity: 2 });
|
|
2808
|
+
const memory = new WebAssembly.Memory({ initial: 1 });
|
|
2809
|
+
const abi = new ProcessABI({
|
|
2810
|
+
processIdentity: f.root.processIdentity,
|
|
2811
|
+
memory,
|
|
2812
|
+
descriptors: f.root.options.descriptors,
|
|
2813
|
+
fs: new MemFS(),
|
|
2814
|
+
pid: f.root.pid,
|
|
2815
|
+
service: f.root,
|
|
2816
|
+
signals: f.root.signals,
|
|
2817
|
+
});
|
|
2818
|
+
const view = new DataView(memory.buffer);
|
|
2819
|
+
const pid = f.root.spawn(1, request());
|
|
2820
|
+
await f.flush();
|
|
2821
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
2822
|
+
const group = directoryJob(f.transport.directory, state.jobSlot, state.job);
|
|
2823
|
+
f.supervisor.exit(pid, 23);
|
|
2824
|
+
const cas = Atomics.compareExchange,
|
|
2825
|
+
load = Atomics.load;
|
|
2826
|
+
let claimed = false,
|
|
2827
|
+
raced = false,
|
|
2828
|
+
nextPid: number | undefined;
|
|
2829
|
+
const retire = () => {
|
|
2830
|
+
raced = true;
|
|
2831
|
+
if (ordering === "before-claim") expect(f.root.waitJob(1, group.id)?.code).toBe(23);
|
|
2832
|
+
else helpDirectoryJobs(f.transport.directory);
|
|
2833
|
+
expectErrno(() => f.root.waitJob(1, group.id), ProcessErrno.CHILD);
|
|
2834
|
+
if (recycle) nextPid = f.root.spawn(1, request());
|
|
2835
|
+
};
|
|
2836
|
+
Atomics.compareExchange = ((
|
|
2837
|
+
array: BigInt64Array,
|
|
2838
|
+
index: number,
|
|
2839
|
+
expected: bigint,
|
|
2840
|
+
replacement: bigint,
|
|
2841
|
+
) => {
|
|
2842
|
+
const target =
|
|
2843
|
+
!raced &&
|
|
2844
|
+
array instanceof BigInt64Array &&
|
|
2845
|
+
array.buffer === f.transport.directory &&
|
|
2846
|
+
array.byteOffset === group.pending.byteOffset &&
|
|
2847
|
+
index === 0 &&
|
|
2848
|
+
expected === packedControl(group.id, 0) &&
|
|
2849
|
+
replacement === packedControl(group.id, -1);
|
|
2850
|
+
if (target && ordering === "before-claim") retire();
|
|
2851
|
+
const previous = cas(array, index, expected, replacement);
|
|
2852
|
+
if (target && previous === expected) claimed = true;
|
|
2853
|
+
if (target && ordering === "after-claim") retire();
|
|
2854
|
+
return previous;
|
|
2855
|
+
}) as typeof Atomics.compareExchange;
|
|
2856
|
+
Atomics.load = ((array: BigInt64Array, index: number) => {
|
|
2857
|
+
if (
|
|
2858
|
+
ordering === "helper-header" &&
|
|
2859
|
+
claimed &&
|
|
2860
|
+
!raced &&
|
|
2861
|
+
array instanceof BigInt64Array &&
|
|
2862
|
+
array.buffer === f.transport.directory &&
|
|
2863
|
+
array.byteOffset + index * 8 === group.pending.byteOffset
|
|
2864
|
+
)
|
|
2865
|
+
retire();
|
|
2866
|
+
return load(array, index);
|
|
2867
|
+
}) as typeof Atomics.load;
|
|
2868
|
+
view.setInt32(64, -99, true);
|
|
2869
|
+
view.setInt32(68, -99, true);
|
|
2870
|
+
let result: number;
|
|
2871
|
+
try {
|
|
2872
|
+
result = abi.imports.wait_job!(group.id, 1, 64);
|
|
2873
|
+
} finally {
|
|
2874
|
+
Atomics.compareExchange = cas;
|
|
2875
|
+
Atomics.load = load;
|
|
2876
|
+
}
|
|
2877
|
+
expect(raced).toBe(true);
|
|
2878
|
+
expect(result).toBe(ordering === "before-claim" ? -ProcessErrno.CHILD : 0);
|
|
2879
|
+
expect(view.getInt32(64, true)).toBe(ordering === "before-claim" ? -99 : 0);
|
|
2880
|
+
expect(view.getInt32(68, true)).toBe(ordering === "before-claim" ? -99 : 23);
|
|
2881
|
+
expect(abi.imports.wait_job!(group.id, 1, 64)).toBe(-ProcessErrno.CHILD);
|
|
2882
|
+
expect(abi.imports.wait_job!(999999, 1, 64)).toBe(-ProcessErrno.SRCH);
|
|
2883
|
+
expectErrno(() => controlCas(group.pending, 0, 0, 9), ProcessErrno.SRCH);
|
|
2884
|
+
if (nextPid !== undefined) {
|
|
2885
|
+
const next = workerProcessState(
|
|
2886
|
+
f.messages.find((message) => message.operation === "spawn")!.transport,
|
|
2887
|
+
);
|
|
2888
|
+
expect(next.pid).toBe(nextPid);
|
|
2889
|
+
expect(next.jobSlot).toBe(group.slot);
|
|
2890
|
+
expect(controlLoad(next.jobPending)).toBe(1);
|
|
2891
|
+
expect(readOutcome(next.jobOutcome)).toBeNull();
|
|
2892
|
+
}
|
|
2893
|
+
await f.flush();
|
|
2894
|
+
});
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
for (const snapshot of ["authorization", "readiness", "outcome", "collection-readiness"] as const) {
|
|
2898
|
+
test(`a competing collector during the ${snapshot} snapshot reports ECHILD`, async () => {
|
|
2899
|
+
const f = fixture({ capacity: 2 });
|
|
2900
|
+
const pid = f.root.spawn(1, request());
|
|
2901
|
+
await f.flush();
|
|
2902
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
2903
|
+
const group = directoryJob(f.transport.directory, state.jobSlot, state.job);
|
|
2904
|
+
f.supervisor.exit(pid, 23);
|
|
2905
|
+
const offset =
|
|
2906
|
+
snapshot === "authorization"
|
|
2907
|
+
? group.controlParent.byteOffset
|
|
2908
|
+
: snapshot === "outcome"
|
|
2909
|
+
? group.outcome.byteOffset
|
|
2910
|
+
: group.pending.byteOffset;
|
|
2911
|
+
const selectedRead = snapshot === "readiness" ? 2 : snapshot === "collection-readiness" ? 3 : 1;
|
|
2912
|
+
const original = Atomics.load;
|
|
2913
|
+
let reads = 0,
|
|
2914
|
+
raced = false;
|
|
2915
|
+
Atomics.load = ((array: BigInt64Array, index: number) => {
|
|
2916
|
+
const target =
|
|
2917
|
+
!raced &&
|
|
2918
|
+
array instanceof BigInt64Array &&
|
|
2919
|
+
array.buffer === f.transport.directory &&
|
|
2920
|
+
array.byteOffset + index * 8 === offset;
|
|
2921
|
+
if (target && ++reads === selectedRead) {
|
|
2922
|
+
raced = true;
|
|
2923
|
+
expect(f.root.waitJob(1, group.id)?.code).toBe(23);
|
|
2924
|
+
f.root.spawn(1, request());
|
|
2925
|
+
}
|
|
2926
|
+
return original(array, index);
|
|
2927
|
+
}) as typeof Atomics.load;
|
|
2928
|
+
try {
|
|
2929
|
+
expectErrno(() => f.root.waitJob(1, group.id), ProcessErrno.CHILD);
|
|
2930
|
+
} finally {
|
|
2931
|
+
Atomics.load = original;
|
|
2932
|
+
}
|
|
2933
|
+
expect(raced).toBe(true);
|
|
2934
|
+
await f.flush();
|
|
2935
|
+
});
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
test("a sealed pending job reports ECHILD while its header remains live", async () => {
|
|
2939
|
+
const f = fixture({ capacity: 2 });
|
|
2940
|
+
const memory = new WebAssembly.Memory({ initial: 1 });
|
|
2941
|
+
const view = new DataView(memory.buffer);
|
|
2942
|
+
view.setInt32(64, -99, true);
|
|
2943
|
+
view.setInt32(68, -99, true);
|
|
2944
|
+
const abi = new ProcessABI({
|
|
2945
|
+
processIdentity: f.root.processIdentity,
|
|
2946
|
+
memory,
|
|
2947
|
+
descriptors: f.root.options.descriptors,
|
|
2948
|
+
fs: new MemFS(),
|
|
2949
|
+
pid: f.root.pid,
|
|
2950
|
+
service: f.root,
|
|
2951
|
+
signals: f.root.signals,
|
|
2952
|
+
});
|
|
2953
|
+
const pid = f.root.spawn(1, request());
|
|
2954
|
+
await f.flush();
|
|
2955
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
2956
|
+
const group = directoryJob(f.transport.directory, state.jobSlot, state.job);
|
|
2957
|
+
f.supervisor.exit(pid, 23);
|
|
2958
|
+
const original = Atomics.load;
|
|
2959
|
+
let sealed = false;
|
|
2960
|
+
Atomics.load = ((array: BigInt64Array, index: number) => {
|
|
2961
|
+
const target =
|
|
2962
|
+
!sealed &&
|
|
2963
|
+
array instanceof BigInt64Array &&
|
|
2964
|
+
array.buffer === f.transport.directory &&
|
|
2965
|
+
array.byteOffset + index * 8 === group.outcome.byteOffset;
|
|
2966
|
+
if (target) {
|
|
2967
|
+
sealed = true;
|
|
2968
|
+
const pending = new BigInt64Array(f.transport.directory, group.pending.byteOffset, 1);
|
|
2969
|
+
expect(
|
|
2970
|
+
Atomics.compareExchange(
|
|
2971
|
+
pending,
|
|
2972
|
+
0,
|
|
2973
|
+
packedControl(group.id, 0),
|
|
2974
|
+
packedControl(group.id, -1),
|
|
2975
|
+
),
|
|
2976
|
+
).toBe(packedControl(group.id, 0));
|
|
2977
|
+
const header = new BigInt64Array(f.transport.directory, group.outcome.byteOffset - 24, 1);
|
|
2978
|
+
expect(Atomics.load(header, 0)).toBe(packedControl(group.id, 1));
|
|
2979
|
+
}
|
|
2980
|
+
return original(array, index);
|
|
2981
|
+
}) as typeof Atomics.load;
|
|
2982
|
+
try {
|
|
2983
|
+
expect(abi.imports.wait_job!(group.id, 1, 64)).toBe(-ProcessErrno.CHILD);
|
|
2984
|
+
} finally {
|
|
2985
|
+
Atomics.load = original;
|
|
2986
|
+
}
|
|
2987
|
+
expect(sealed).toBe(true);
|
|
2988
|
+
expect(view.getInt32(64, true)).toBe(-99);
|
|
2989
|
+
expect(view.getInt32(68, true)).toBe(-99);
|
|
2990
|
+
expect(controlLoad(group.pending)).toBe(-1);
|
|
2991
|
+
expect(readOutcome(group.outcome)).toMatchObject({ kind: "exited", code: 23 });
|
|
2992
|
+
helpDirectoryJobs(f.transport.directory);
|
|
2993
|
+
await f.flush();
|
|
2994
|
+
});
|
|
2995
|
+
|
|
2996
|
+
for (const boundary of ["load", "compareExchange"] as const) {
|
|
2997
|
+
test(`failed-start retirement tolerates a public job reap racing its ${boundary}`, async () => {
|
|
2998
|
+
const launch = Promise.withResolvers<ProcessHandle>();
|
|
2999
|
+
const errors: unknown[] = [];
|
|
3000
|
+
const f = fixture({
|
|
3001
|
+
capacity: 3,
|
|
3002
|
+
launch: () => launch.promise,
|
|
3003
|
+
onError: (error) => errors.push(error),
|
|
3004
|
+
});
|
|
3005
|
+
const pid = f.root.spawn(1, request());
|
|
3006
|
+
await f.flush();
|
|
3007
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
3008
|
+
const group = findDirectoryJob(f.transport.directory, state.job)!;
|
|
3009
|
+
const load = Atomics.load,
|
|
3010
|
+
compareExchange = Atomics.compareExchange;
|
|
3011
|
+
let raced = false;
|
|
3012
|
+
const reap = (array: BigInt64Array) => {
|
|
3013
|
+
if (
|
|
3014
|
+
raced ||
|
|
3015
|
+
array.buffer !== f.transport.directory ||
|
|
3016
|
+
array.byteOffset !== group.retirement.byteOffset
|
|
3017
|
+
)
|
|
3018
|
+
return;
|
|
3019
|
+
raced = true;
|
|
3020
|
+
expect(f.root.waitJob(1, state.job)).toMatchObject({ kind: "start-failed", error: "EIO" });
|
|
3021
|
+
f.root.spawn(1, request());
|
|
3022
|
+
};
|
|
3023
|
+
const racingLoad = (array: BigInt64Array, index: number) => {
|
|
3024
|
+
const value = load(array, index);
|
|
3025
|
+
reap(array);
|
|
3026
|
+
return value;
|
|
3027
|
+
};
|
|
3028
|
+
const racingCas = (array: BigInt64Array, index: number, expected: bigint, value: bigint) => {
|
|
3029
|
+
reap(array);
|
|
3030
|
+
return compareExchange(array, index, expected, value);
|
|
3031
|
+
};
|
|
3032
|
+
try {
|
|
3033
|
+
if (boundary === "load") Atomics.load = racingLoad as typeof Atomics.load;
|
|
3034
|
+
else Atomics.compareExchange = racingCas as typeof Atomics.compareExchange;
|
|
3035
|
+
const rejection = new Error("intentional adapter startup rejection");
|
|
3036
|
+
launch.reject(rejection);
|
|
3037
|
+
await f.supervisor.start(pid);
|
|
3038
|
+
for (let turn = 0; turn < 12; turn++) await Promise.resolve();
|
|
3039
|
+
expect(raced).toBe(true);
|
|
3040
|
+
expect(errors).toEqual([rejection]);
|
|
3041
|
+
const replacement = workerProcessState(
|
|
3042
|
+
f.messages.find((message) => message.operation === "spawn")!.transport,
|
|
3043
|
+
);
|
|
3044
|
+
expect(replacement.jobSlot).toBe(group.slot);
|
|
3045
|
+
expect(controlLoad(replacement.jobPending)).toBe(1);
|
|
3046
|
+
expect(
|
|
3047
|
+
controlLoad(findDirectoryJob(f.transport.directory, replacement.job)!.retirement),
|
|
3048
|
+
).toBe(0);
|
|
3049
|
+
expect(readOutcome(replacement.jobOutcome)).toBeNull();
|
|
3050
|
+
} finally {
|
|
3051
|
+
Atomics.load = load;
|
|
3052
|
+
Atomics.compareExchange = compareExchange;
|
|
3053
|
+
launch.reject(new Error("cleanup"));
|
|
3054
|
+
}
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
3057
|
+
|
|
3058
|
+
test("retirement publication preserves physical-stop debt and failure", async () => {
|
|
3059
|
+
const stopping = Promise.withResolvers<void>();
|
|
3060
|
+
const errors: unknown[] = [];
|
|
3061
|
+
const f = fixture({ terminate: () => stopping.promise, onError: (error) => errors.push(error) });
|
|
3062
|
+
const pid = f.root.spawn(1, request());
|
|
3063
|
+
await f.flush();
|
|
3064
|
+
await f.supervisor.start(pid);
|
|
3065
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
3066
|
+
const group = findDirectoryJob(f.transport.directory, state.job)!;
|
|
3067
|
+
f.supervisor.exit(pid, 0);
|
|
3068
|
+
expect(f.root.jobEmpty(1, state.job)).toBe(true);
|
|
3069
|
+
expect(f.root.jobCleanupReady(1, state.job)).toBe(false);
|
|
3070
|
+
expect(controlLoad(group.retirement)).toBe(0);
|
|
3071
|
+
const failure = new Error("physical stop failed");
|
|
3072
|
+
stopping.reject(failure);
|
|
3073
|
+
for (let turn = 0; turn < 12; turn++) await Promise.resolve();
|
|
3074
|
+
expect(controlLoad(group.retirement)).toBe(-29);
|
|
3075
|
+
expectErrno(() => f.root.jobCleanupReady(1, state.job), 29);
|
|
3076
|
+
expect(errors).toEqual([failure]);
|
|
3077
|
+
});
|
|
3078
|
+
|
|
3079
|
+
test("a late handle acquired after cancellation remains retirement debt until physical stop", async () => {
|
|
3080
|
+
const admission = Promise.withResolvers<ProcessHandle>();
|
|
3081
|
+
const stopping = Promise.withResolvers<void>();
|
|
3082
|
+
const launched = Promise.withResolvers<void>();
|
|
3083
|
+
let stops = 0;
|
|
3084
|
+
const f = fixture({
|
|
3085
|
+
launch() {
|
|
3086
|
+
launched.resolve();
|
|
3087
|
+
return admission.promise;
|
|
3088
|
+
},
|
|
3089
|
+
});
|
|
3090
|
+
const pid = f.root.spawn(1, request());
|
|
3091
|
+
await f.flush();
|
|
3092
|
+
await launched.promise;
|
|
3093
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
3094
|
+
f.supervisor.kill(pid, 9);
|
|
3095
|
+
const starting = f.supervisor.start(pid);
|
|
3096
|
+
expect(f.root.jobCleanupReady(1, state.job)).toBe(false);
|
|
3097
|
+
admission.resolve({
|
|
3098
|
+
terminate() {
|
|
3099
|
+
stops++;
|
|
3100
|
+
return stopping.promise;
|
|
3101
|
+
},
|
|
3102
|
+
});
|
|
3103
|
+
try {
|
|
3104
|
+
await starting;
|
|
3105
|
+
expect(stops).toBe(1);
|
|
3106
|
+
expect(f.root.jobCleanupReady(1, state.job)).toBe(false);
|
|
3107
|
+
stopping.resolve();
|
|
3108
|
+
for (let turn = 0; turn < 12; turn++) await Promise.resolve();
|
|
3109
|
+
expect(f.root.jobCleanupReady(1, state.job)).toBe(true);
|
|
3110
|
+
expect(f.root.waitJob(1, state.job)).toMatchObject({ kind: "signaled", code: 9 });
|
|
3111
|
+
} finally {
|
|
3112
|
+
admission.resolve({ terminate() {} });
|
|
3113
|
+
stopping.resolve();
|
|
3114
|
+
await starting;
|
|
3115
|
+
}
|
|
3116
|
+
});
|
|
3117
|
+
|
|
3118
|
+
test("retirement publication reports SRCH while its captured job remains live", async () => {
|
|
3119
|
+
const launch = Promise.withResolvers<ProcessHandle>();
|
|
3120
|
+
const errors: unknown[] = [];
|
|
3121
|
+
const f = fixture({ launch: () => launch.promise, onError: (error) => errors.push(error) });
|
|
3122
|
+
const pid = f.root.spawn(1, request());
|
|
3123
|
+
await f.flush();
|
|
3124
|
+
const state = workerProcessState(f.broker.get(pid)!);
|
|
3125
|
+
const group = findDirectoryJob(f.transport.directory, state.job)!;
|
|
3126
|
+
const load = Atomics.load;
|
|
3127
|
+
const error = new ProcessError(ProcessErrno.SRCH, "live retirement store failed");
|
|
3128
|
+
let injected = false;
|
|
3129
|
+
const failingLoad = (array: BigInt64Array, index: number) => {
|
|
3130
|
+
if (
|
|
3131
|
+
!injected &&
|
|
3132
|
+
array.buffer === f.transport.directory &&
|
|
3133
|
+
array.byteOffset === group.retirement.byteOffset
|
|
3134
|
+
) {
|
|
3135
|
+
injected = true;
|
|
3136
|
+
throw error;
|
|
3137
|
+
}
|
|
3138
|
+
return load(array, index);
|
|
3139
|
+
};
|
|
3140
|
+
try {
|
|
3141
|
+
Atomics.load = failingLoad as typeof Atomics.load;
|
|
3142
|
+
const rejection = new Error("intentional adapter startup rejection");
|
|
3143
|
+
launch.reject(rejection);
|
|
3144
|
+
await f.supervisor.start(pid);
|
|
3145
|
+
for (let turn = 0; turn < 12; turn++) await Promise.resolve();
|
|
3146
|
+
expect(injected).toBe(true);
|
|
3147
|
+
expect(group.retirement.valid()).toBe(true);
|
|
3148
|
+
expect(errors).toEqual([rejection, error]);
|
|
3149
|
+
} finally {
|
|
3150
|
+
Atomics.load = load;
|
|
3151
|
+
launch.reject(new Error("cleanup"));
|
|
3152
|
+
}
|
|
3153
|
+
});
|