@gpustack/loopwright 0.0.0-stage → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +356 -2
- package/bin/loopwright.js +3 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter-v2.d.ts +9 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter-v2.js +122 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter.d.ts +30 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter.js +340 -0
- package/node_modules/@loopwright/agent-pi/dist/admission.d.ts +25 -0
- package/node_modules/@loopwright/agent-pi/dist/admission.js +65 -0
- package/node_modules/@loopwright/agent-pi/dist/artifacts.d.ts +15 -0
- package/node_modules/@loopwright/agent-pi/dist/artifacts.js +76 -0
- package/node_modules/@loopwright/agent-pi/dist/boundary.d.ts +18 -0
- package/node_modules/@loopwright/agent-pi/dist/boundary.js +113 -0
- package/node_modules/@loopwright/agent-pi/dist/broker-channel.d.ts +4 -0
- package/node_modules/@loopwright/agent-pi/dist/broker-channel.js +121 -0
- package/node_modules/@loopwright/agent-pi/dist/candidate.d.ts +96 -0
- package/node_modules/@loopwright/agent-pi/dist/candidate.js +1712 -0
- package/node_modules/@loopwright/agent-pi/dist/capture.d.ts +39 -0
- package/node_modules/@loopwright/agent-pi/dist/capture.js +146 -0
- package/node_modules/@loopwright/agent-pi/dist/cas.d.ts +51 -0
- package/node_modules/@loopwright/agent-pi/dist/cas.js +836 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog-api.d.ts +3 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog-api.js +2 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog.d.ts +39 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog.js +280 -0
- package/node_modules/@loopwright/agent-pi/dist/circuit-breaker-limits.d.ts +9 -0
- package/node_modules/@loopwright/agent-pi/dist/circuit-breaker-limits.js +12 -0
- package/node_modules/@loopwright/agent-pi/dist/containers.d.ts +29 -0
- package/node_modules/@loopwright/agent-pi/dist/containers.js +160 -0
- package/node_modules/@loopwright/agent-pi/dist/context.d.ts +56 -0
- package/node_modules/@loopwright/agent-pi/dist/context.js +351 -0
- package/node_modules/@loopwright/agent-pi/dist/daemon.d.ts +8 -0
- package/node_modules/@loopwright/agent-pi/dist/daemon.js +52 -0
- package/node_modules/@loopwright/agent-pi/dist/deadline.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/deadline.js +18 -0
- package/node_modules/@loopwright/agent-pi/dist/decode-capture.d.ts +39 -0
- package/node_modules/@loopwright/agent-pi/dist/decode-capture.js +287 -0
- package/node_modules/@loopwright/agent-pi/dist/descriptor.d.ts +12 -0
- package/node_modules/@loopwright/agent-pi/dist/descriptor.js +17 -0
- package/node_modules/@loopwright/agent-pi/dist/docker-absence.d.ts +2 -0
- package/node_modules/@loopwright/agent-pi/dist/docker-absence.js +9 -0
- package/node_modules/@loopwright/agent-pi/dist/errors.d.ts +7 -0
- package/node_modules/@loopwright/agent-pi/dist/errors.js +19 -0
- package/node_modules/@loopwright/agent-pi/dist/event-sequence.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/event-sequence.js +64 -0
- package/node_modules/@loopwright/agent-pi/dist/events.d.ts +19 -0
- package/node_modules/@loopwright/agent-pi/dist/events.js +132 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-guard.d.ts +9 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-guard.js +25 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-lease.d.ts +24 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-lease.js +316 -0
- package/node_modules/@loopwright/agent-pi/dist/execution.d.ts +32 -0
- package/node_modules/@loopwright/agent-pi/dist/execution.js +476 -0
- package/node_modules/@loopwright/agent-pi/dist/external-mcp.d.ts +87 -0
- package/node_modules/@loopwright/agent-pi/dist/external-mcp.js +526 -0
- package/node_modules/@loopwright/agent-pi/dist/factory-bootstrap.d.ts +15 -0
- package/node_modules/@loopwright/agent-pi/dist/factory-bootstrap.js +74 -0
- package/node_modules/@loopwright/agent-pi/dist/host-session.d.ts +51 -0
- package/node_modules/@loopwright/agent-pi/dist/host-session.js +2094 -0
- package/node_modules/@loopwright/agent-pi/dist/http-mcp.d.ts +32 -0
- package/node_modules/@loopwright/agent-pi/dist/http-mcp.js +353 -0
- package/node_modules/@loopwright/agent-pi/dist/index.d.ts +7 -0
- package/node_modules/@loopwright/agent-pi/dist/index.js +4 -0
- package/node_modules/@loopwright/agent-pi/dist/lifecycle.d.ts +13 -0
- package/node_modules/@loopwright/agent-pi/dist/lifecycle.js +11 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-process.d.ts +35 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-process.js +92 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-transport.d.ts +25 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-transport.js +63 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp.d.ts +23 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp.js +212 -0
- package/node_modules/@loopwright/agent-pi/dist/operation.d.ts +5 -0
- package/node_modules/@loopwright/agent-pi/dist/operation.js +28 -0
- package/node_modules/@loopwright/agent-pi/dist/policy-v2.d.ts +10 -0
- package/node_modules/@loopwright/agent-pi/dist/policy-v2.js +64 -0
- package/node_modules/@loopwright/agent-pi/dist/policy.d.ts +13 -0
- package/node_modules/@loopwright/agent-pi/dist/policy.js +260 -0
- package/node_modules/@loopwright/agent-pi/dist/preflight.d.ts +60 -0
- package/node_modules/@loopwright/agent-pi/dist/preflight.js +700 -0
- package/node_modules/@loopwright/agent-pi/dist/progress-summary.d.ts +1 -0
- package/node_modules/@loopwright/agent-pi/dist/progress-summary.js +119 -0
- package/node_modules/@loopwright/agent-pi/dist/protocol.d.ts +17 -0
- package/node_modules/@loopwright/agent-pi/dist/protocol.js +131 -0
- package/node_modules/@loopwright/agent-pi/dist/provider.d.ts +62 -0
- package/node_modules/@loopwright/agent-pi/dist/provider.js +217 -0
- package/node_modules/@loopwright/agent-pi/dist/receipt.d.ts +3 -0
- package/node_modules/@loopwright/agent-pi/dist/receipt.js +64 -0
- package/node_modules/@loopwright/agent-pi/dist/recovery.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/recovery.js +188 -0
- package/node_modules/@loopwright/agent-pi/dist/resources.d.ts +13 -0
- package/node_modules/@loopwright/agent-pi/dist/resources.js +81 -0
- package/node_modules/@loopwright/agent-pi/dist/response.d.ts +20 -0
- package/node_modules/@loopwright/agent-pi/dist/response.js +259 -0
- package/node_modules/@loopwright/agent-pi/dist/runtime-profile.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/runtime-profile.js +37 -0
- package/node_modules/@loopwright/agent-pi/dist/sdk-worker.d.ts +14 -0
- package/node_modules/@loopwright/agent-pi/dist/sdk-worker.js +633 -0
- package/node_modules/@loopwright/agent-pi/dist/sender.d.ts +46 -0
- package/node_modules/@loopwright/agent-pi/dist/sender.js +553 -0
- package/node_modules/@loopwright/agent-pi/dist/session-host.d.ts +21 -0
- package/node_modules/@loopwright/agent-pi/dist/session-host.js +315 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot-transfer.d.ts +14 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot-transfer.js +102 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot.d.ts +19 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot.js +121 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-process.d.ts +32 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-process.js +85 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-worker.d.ts +2 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-worker.js +105 -0
- package/node_modules/@loopwright/agent-pi/dist/tools.d.ts +36 -0
- package/node_modules/@loopwright/agent-pi/dist/tools.js +128 -0
- package/node_modules/@loopwright/agent-pi/dist/types-v2.d.ts +71 -0
- package/node_modules/@loopwright/agent-pi/dist/types-v2.js +1 -0
- package/node_modules/@loopwright/agent-pi/dist/types.d.ts +314 -0
- package/node_modules/@loopwright/agent-pi/dist/types.js +1 -0
- package/node_modules/@loopwright/agent-pi/dist/usage.d.ts +18 -0
- package/node_modules/@loopwright/agent-pi/dist/usage.js +314 -0
- package/node_modules/@loopwright/agent-pi/dist/workspace-mcp.d.ts +27 -0
- package/node_modules/@loopwright/agent-pi/dist/workspace-mcp.js +142 -0
- package/node_modules/@loopwright/agent-pi/package.json +24 -0
- package/node_modules/@loopwright/agent-pi/runtime/Dockerfile +8 -0
- package/node_modules/@loopwright/agent-pi/runtime/seccomp.json +1 -0
- package/node_modules/@loopwright/cli/dist/arguments.d.ts +19 -0
- package/node_modules/@loopwright/cli/dist/arguments.js +358 -0
- package/node_modules/@loopwright/cli/dist/closure.d.ts +93 -0
- package/node_modules/@loopwright/cli/dist/closure.js +230 -0
- package/node_modules/@loopwright/cli/dist/draft.d.ts +9 -0
- package/node_modules/@loopwright/cli/dist/draft.js +106 -0
- package/node_modules/@loopwright/cli/dist/failure-matrix.d.ts +9 -0
- package/node_modules/@loopwright/cli/dist/failure-matrix.js +701 -0
- package/node_modules/@loopwright/cli/dist/index.d.ts +6 -0
- package/node_modules/@loopwright/cli/dist/index.js +5 -0
- package/node_modules/@loopwright/cli/dist/main.d.ts +22 -0
- package/node_modules/@loopwright/cli/dist/main.js +1855 -0
- package/node_modules/@loopwright/cli/package.json +16 -0
- package/node_modules/@loopwright/controller/dist/acceptance.d.ts +43 -0
- package/node_modules/@loopwright/controller/dist/acceptance.js +446 -0
- package/node_modules/@loopwright/controller/dist/benchmark-gate.d.ts +273 -0
- package/node_modules/@loopwright/controller/dist/benchmark-gate.js +3147 -0
- package/node_modules/@loopwright/controller/dist/budget-observations.d.ts +25 -0
- package/node_modules/@loopwright/controller/dist/budget-observations.js +139 -0
- package/node_modules/@loopwright/controller/dist/bundle.d.ts +26 -0
- package/node_modules/@loopwright/controller/dist/bundle.js +64 -0
- package/node_modules/@loopwright/controller/dist/capture.d.ts +89 -0
- package/node_modules/@loopwright/controller/dist/capture.js +587 -0
- package/node_modules/@loopwright/controller/dist/compile.d.ts +3 -0
- package/node_modules/@loopwright/controller/dist/compile.js +402 -0
- package/node_modules/@loopwright/controller/dist/config.d.ts +22 -0
- package/node_modules/@loopwright/controller/dist/config.js +255 -0
- package/node_modules/@loopwright/controller/dist/controller.d.ts +177 -0
- package/node_modules/@loopwright/controller/dist/controller.js +2135 -0
- package/node_modules/@loopwright/controller/dist/credentials.d.ts +29 -0
- package/node_modules/@loopwright/controller/dist/credentials.js +189 -0
- package/node_modules/@loopwright/controller/dist/deadlines.d.ts +18 -0
- package/node_modules/@loopwright/controller/dist/deadlines.js +71 -0
- package/node_modules/@loopwright/controller/dist/errors.d.ts +27 -0
- package/node_modules/@loopwright/controller/dist/errors.js +41 -0
- package/node_modules/@loopwright/controller/dist/events.d.ts +52 -0
- package/node_modules/@loopwright/controller/dist/events.js +228 -0
- package/node_modules/@loopwright/controller/dist/files.d.ts +51 -0
- package/node_modules/@loopwright/controller/dist/files.js +386 -0
- package/node_modules/@loopwright/controller/dist/finalize.d.ts +25 -0
- package/node_modules/@loopwright/controller/dist/finalize.js +32 -0
- package/node_modules/@loopwright/controller/dist/gate.d.ts +84 -0
- package/node_modules/@loopwright/controller/dist/gate.js +640 -0
- package/node_modules/@loopwright/controller/dist/git-objects.d.ts +11 -0
- package/node_modules/@loopwright/controller/dist/git-objects.js +59 -0
- package/node_modules/@loopwright/controller/dist/git-reader.d.ts +17 -0
- package/node_modules/@loopwright/controller/dist/git-reader.js +40 -0
- package/node_modules/@loopwright/controller/dist/handlers.d.ts +6 -0
- package/node_modules/@loopwright/controller/dist/handlers.js +45 -0
- package/node_modules/@loopwright/controller/dist/handoff.d.ts +71 -0
- package/node_modules/@loopwright/controller/dist/handoff.js +554 -0
- package/node_modules/@loopwright/controller/dist/index.d.ts +41 -0
- package/node_modules/@loopwright/controller/dist/index.js +21 -0
- package/node_modules/@loopwright/controller/dist/inspect.d.ts +30 -0
- package/node_modules/@loopwright/controller/dist/inspect.js +372 -0
- package/node_modules/@loopwright/controller/dist/interpolation.d.ts +9 -0
- package/node_modules/@loopwright/controller/dist/interpolation.js +79 -0
- package/node_modules/@loopwright/controller/dist/ownership.d.ts +41 -0
- package/node_modules/@loopwright/controller/dist/ownership.js +666 -0
- package/node_modules/@loopwright/controller/dist/parser.d.ts +5 -0
- package/node_modules/@loopwright/controller/dist/parser.js +200 -0
- package/node_modules/@loopwright/controller/dist/progress.d.ts +41 -0
- package/node_modules/@loopwright/controller/dist/progress.js +904 -0
- package/node_modules/@loopwright/controller/dist/publication.d.ts +60 -0
- package/node_modules/@loopwright/controller/dist/publication.js +329 -0
- package/node_modules/@loopwright/controller/dist/reconcile.d.ts +26 -0
- package/node_modules/@loopwright/controller/dist/reconcile.js +1378 -0
- package/node_modules/@loopwright/controller/dist/recovery.d.ts +10 -0
- package/node_modules/@loopwright/controller/dist/recovery.js +315 -0
- package/node_modules/@loopwright/controller/dist/refusal-record.d.ts +43 -0
- package/node_modules/@loopwright/controller/dist/refusal-record.js +150 -0
- package/node_modules/@loopwright/controller/dist/registry.d.ts +6 -0
- package/node_modules/@loopwright/controller/dist/registry.js +374 -0
- package/node_modules/@loopwright/controller/dist/repair.d.ts +31 -0
- package/node_modules/@loopwright/controller/dist/repair.js +102 -0
- package/node_modules/@loopwright/controller/dist/report.d.ts +64 -0
- package/node_modules/@loopwright/controller/dist/report.js +596 -0
- package/node_modules/@loopwright/controller/dist/retained.d.ts +284 -0
- package/node_modules/@loopwright/controller/dist/retained.js +193 -0
- package/node_modules/@loopwright/controller/dist/rules.d.ts +31 -0
- package/node_modules/@loopwright/controller/dist/rules.js +110 -0
- package/node_modules/@loopwright/controller/dist/run-eval.d.ts +115 -0
- package/node_modules/@loopwright/controller/dist/run-eval.js +959 -0
- package/node_modules/@loopwright/controller/dist/scheduler.d.ts +10 -0
- package/node_modules/@loopwright/controller/dist/scheduler.js +41 -0
- package/node_modules/@loopwright/controller/dist/schema.d.ts +17 -0
- package/node_modules/@loopwright/controller/dist/schema.js +78 -0
- package/node_modules/@loopwright/controller/dist/source.d.ts +69 -0
- package/node_modules/@loopwright/controller/dist/source.js +872 -0
- package/node_modules/@loopwright/controller/dist/step.d.ts +38 -0
- package/node_modules/@loopwright/controller/dist/step.js +1776 -0
- package/node_modules/@loopwright/controller/dist/storage.d.ts +90 -0
- package/node_modules/@loopwright/controller/dist/storage.js +1345 -0
- package/node_modules/@loopwright/controller/dist/submission.d.ts +51 -0
- package/node_modules/@loopwright/controller/dist/submission.js +292 -0
- package/node_modules/@loopwright/controller/dist/types.d.ts +585 -0
- package/node_modules/@loopwright/controller/dist/types.js +9 -0
- package/node_modules/@loopwright/controller/dist/verification.d.ts +124 -0
- package/node_modules/@loopwright/controller/dist/verification.js +1308 -0
- package/node_modules/@loopwright/controller/dist/verifier-protocol.d.ts +105 -0
- package/node_modules/@loopwright/controller/dist/verifier-protocol.js +1312 -0
- package/node_modules/@loopwright/controller/dist/verifier-worker.d.ts +1 -0
- package/node_modules/@loopwright/controller/dist/verifier-worker.js +33 -0
- package/node_modules/@loopwright/controller/package.json +12 -0
- package/node_modules/@loopwright/core/dist/acceptance.d.ts +108 -0
- package/node_modules/@loopwright/core/dist/acceptance.js +327 -0
- package/node_modules/@loopwright/core/dist/artifacts.d.ts +63 -0
- package/node_modules/@loopwright/core/dist/artifacts.js +356 -0
- package/node_modules/@loopwright/core/dist/boundary.d.ts +21 -0
- package/node_modules/@loopwright/core/dist/boundary.js +484 -0
- package/node_modules/@loopwright/core/dist/contracts.d.ts +287 -0
- package/node_modules/@loopwright/core/dist/contracts.js +694 -0
- package/node_modules/@loopwright/core/dist/diagnostics.d.ts +21 -0
- package/node_modules/@loopwright/core/dist/diagnostics.js +51 -0
- package/node_modules/@loopwright/core/dist/evidence.d.ts +92 -0
- package/node_modules/@loopwright/core/dist/evidence.js +85 -0
- package/node_modules/@loopwright/core/dist/graph.d.ts +8 -0
- package/node_modules/@loopwright/core/dist/graph.js +44 -0
- package/node_modules/@loopwright/core/dist/identity.d.ts +162 -0
- package/node_modules/@loopwright/core/dist/identity.js +80 -0
- package/node_modules/@loopwright/core/dist/index.d.ts +30 -0
- package/node_modules/@loopwright/core/dist/index.js +39 -0
- package/node_modules/@loopwright/core/dist/limits.d.ts +99 -0
- package/node_modules/@loopwright/core/dist/limits.js +59 -0
- package/node_modules/@loopwright/core/dist/results.d.ts +161 -0
- package/node_modules/@loopwright/core/dist/results.js +98 -0
- package/node_modules/@loopwright/core/dist/scope.d.ts +13 -0
- package/node_modules/@loopwright/core/dist/scope.js +154 -0
- package/node_modules/@loopwright/core/dist/scrubber.d.ts +13 -0
- package/node_modules/@loopwright/core/dist/scrubber.js +63 -0
- package/node_modules/@loopwright/core/dist/usage.d.ts +68 -0
- package/node_modules/@loopwright/core/dist/usage.js +56 -0
- package/node_modules/@loopwright/core/package.json +12 -0
- package/node_modules/@loopwright/decisions/dist/benchmark.d.ts +23 -0
- package/node_modules/@loopwright/decisions/dist/benchmark.js +337 -0
- package/node_modules/@loopwright/decisions/dist/client.d.ts +74 -0
- package/node_modules/@loopwright/decisions/dist/client.js +292 -0
- package/node_modules/@loopwright/decisions/dist/index.d.ts +15 -0
- package/node_modules/@loopwright/decisions/dist/index.js +8 -0
- package/node_modules/@loopwright/decisions/dist/nodes.d.ts +63 -0
- package/node_modules/@loopwright/decisions/dist/nodes.js +282 -0
- package/node_modules/@loopwright/decisions/dist/primitives.d.ts +36 -0
- package/node_modules/@loopwright/decisions/dist/primitives.js +300 -0
- package/node_modules/@loopwright/decisions/dist/redaction.d.ts +23 -0
- package/node_modules/@loopwright/decisions/dist/redaction.js +146 -0
- package/node_modules/@loopwright/decisions/dist/router.d.ts +55 -0
- package/node_modules/@loopwright/decisions/dist/router.js +248 -0
- package/node_modules/@loopwright/decisions/dist/schema.d.ts +25 -0
- package/node_modules/@loopwright/decisions/dist/schema.js +536 -0
- package/node_modules/@loopwright/decisions/dist/types.d.ts +394 -0
- package/node_modules/@loopwright/decisions/dist/types.js +80 -0
- package/node_modules/@loopwright/decisions/package.json +12 -0
- package/node_modules/@loopwright/github-app/dist/action.d.ts +90 -0
- package/node_modules/@loopwright/github-app/dist/action.js +2429 -0
- package/node_modules/@loopwright/github-app/dist/config.d.ts +23 -0
- package/node_modules/@loopwright/github-app/dist/config.js +297 -0
- package/node_modules/@loopwright/github-app/dist/digests.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/digests.js +1 -0
- package/node_modules/@loopwright/github-app/dist/index.d.ts +14 -0
- package/node_modules/@loopwright/github-app/dist/index.js +13 -0
- package/node_modules/@loopwright/github-app/dist/models-config.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/models-config.js +1 -0
- package/node_modules/@loopwright/github-app/dist/output-format.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/output-format.js +1 -0
- package/node_modules/@loopwright/github-app/dist/preflight.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/preflight.js +1 -0
- package/node_modules/@loopwright/github-app/dist/publisher.d.ts +58 -0
- package/node_modules/@loopwright/github-app/dist/publisher.js +1368 -0
- package/node_modules/@loopwright/github-app/dist/qualification.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/qualification.js +1 -0
- package/node_modules/@loopwright/github-app/dist/sandbox.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/sandbox.js +1 -0
- package/node_modules/@loopwright/github-app/dist/schema.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/schema.js +1 -0
- package/node_modules/@loopwright/github-app/dist/service.d.ts +52 -0
- package/node_modules/@loopwright/github-app/dist/service.js +1658 -0
- package/node_modules/@loopwright/github-app/dist/suite-pr-lookup.d.ts +90 -0
- package/node_modules/@loopwright/github-app/dist/suite-pr-lookup.js +392 -0
- package/node_modules/@loopwright/github-app/dist/taskpack.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/taskpack.js +1 -0
- package/node_modules/@loopwright/github-app/dist/tenant-queue.d.ts +44 -0
- package/node_modules/@loopwright/github-app/dist/tenant-queue.js +423 -0
- package/node_modules/@loopwright/github-app/dist/token-broker.d.ts +50 -0
- package/node_modules/@loopwright/github-app/dist/token-broker.js +262 -0
- package/node_modules/@loopwright/github-app/dist/turnkey-memory.d.ts +35 -0
- package/node_modules/@loopwright/github-app/dist/turnkey-memory.js +1654 -0
- package/node_modules/@loopwright/github-app/dist/turnkey.d.ts +16 -0
- package/node_modules/@loopwright/github-app/dist/turnkey.js +34 -0
- package/node_modules/@loopwright/github-app/dist/types.d.ts +220 -0
- package/node_modules/@loopwright/github-app/dist/types.js +14 -0
- package/node_modules/@loopwright/github-app/dist/upstreams.d.ts +13 -0
- package/node_modules/@loopwright/github-app/dist/upstreams.js +65 -0
- package/node_modules/@loopwright/github-app/dist/webhook.d.ts +34 -0
- package/node_modules/@loopwright/github-app/dist/webhook.js +241 -0
- package/node_modules/@loopwright/github-app/dist/yaml.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/yaml.js +1 -0
- package/node_modules/@loopwright/github-app/package.json +12 -0
- package/node_modules/@loopwright/hardware-runner/dist/config.d.ts +48 -0
- package/node_modules/@loopwright/hardware-runner/dist/config.js +719 -0
- package/node_modules/@loopwright/hardware-runner/dist/evaluator.d.ts +230 -0
- package/node_modules/@loopwright/hardware-runner/dist/evaluator.js +3178 -0
- package/node_modules/@loopwright/hardware-runner/dist/index.d.ts +13 -0
- package/node_modules/@loopwright/hardware-runner/dist/index.js +9 -0
- package/node_modules/@loopwright/hardware-runner/dist/provenance.d.ts +128 -0
- package/node_modules/@loopwright/hardware-runner/dist/provenance.js +1500 -0
- package/node_modules/@loopwright/hardware-runner/dist/queue.d.ts +81 -0
- package/node_modules/@loopwright/hardware-runner/dist/queue.js +1081 -0
- package/node_modules/@loopwright/hardware-runner/dist/relay-server.d.ts +13 -0
- package/node_modules/@loopwright/hardware-runner/dist/relay-server.js +2997 -0
- package/node_modules/@loopwright/hardware-runner/dist/types.d.ts +239 -0
- package/node_modules/@loopwright/hardware-runner/dist/types.js +12 -0
- package/node_modules/@loopwright/hardware-runner/dist/worker.d.ts +49 -0
- package/node_modules/@loopwright/hardware-runner/dist/worker.js +1648 -0
- package/node_modules/@loopwright/hardware-runner/package.json +12 -0
- package/node_modules/@loopwright/memory/dist/cas.d.ts +21 -0
- package/node_modules/@loopwright/memory/dist/cas.js +510 -0
- package/node_modules/@loopwright/memory/dist/compaction.d.ts +18 -0
- package/node_modules/@loopwright/memory/dist/compaction.js +110 -0
- package/node_modules/@loopwright/memory/dist/finalizer.d.ts +23 -0
- package/node_modules/@loopwright/memory/dist/finalizer.js +538 -0
- package/node_modules/@loopwright/memory/dist/index.d.ts +9 -0
- package/node_modules/@loopwright/memory/dist/index.js +8 -0
- package/node_modules/@loopwright/memory/dist/schema.d.ts +36 -0
- package/node_modules/@loopwright/memory/dist/schema.js +510 -0
- package/node_modules/@loopwright/memory/dist/selector.d.ts +7 -0
- package/node_modules/@loopwright/memory/dist/selector.js +157 -0
- package/node_modules/@loopwright/memory/dist/store.d.ts +51 -0
- package/node_modules/@loopwright/memory/dist/store.js +554 -0
- package/node_modules/@loopwright/memory/dist/types.d.ts +442 -0
- package/node_modules/@loopwright/memory/dist/types.js +8 -0
- package/node_modules/@loopwright/memory/dist/verifier.d.ts +5 -0
- package/node_modules/@loopwright/memory/dist/verifier.js +328 -0
- package/node_modules/@loopwright/memory/package.json +12 -0
- package/node_modules/@loopwright/state/dist/admission.d.ts +321 -0
- package/node_modules/@loopwright/state/dist/admission.js +199 -0
- package/node_modules/@loopwright/state/dist/boundary.d.ts +53 -0
- package/node_modules/@loopwright/state/dist/boundary.js +194 -0
- package/node_modules/@loopwright/state/dist/checkpoint.d.ts +16 -0
- package/node_modules/@loopwright/state/dist/checkpoint.js +84 -0
- package/node_modules/@loopwright/state/dist/clock.d.ts +8 -0
- package/node_modules/@loopwright/state/dist/clock.js +27 -0
- package/node_modules/@loopwright/state/dist/connection.d.ts +55 -0
- package/node_modules/@loopwright/state/dist/connection.js +391 -0
- package/node_modules/@loopwright/state/dist/errors.d.ts +13 -0
- package/node_modules/@loopwright/state/dist/errors.js +34 -0
- package/node_modules/@loopwright/state/dist/index.d.ts +3 -0
- package/node_modules/@loopwright/state/dist/index.js +1 -0
- package/node_modules/@loopwright/state/dist/journal.d.ts +119 -0
- package/node_modules/@loopwright/state/dist/journal.js +72 -0
- package/node_modules/@loopwright/state/dist/model.d.ts +40 -0
- package/node_modules/@loopwright/state/dist/model.js +58 -0
- package/node_modules/@loopwright/state/dist/ownership.d.ts +14 -0
- package/node_modules/@loopwright/state/dist/ownership.js +45 -0
- package/node_modules/@loopwright/state/dist/pages.d.ts +11 -0
- package/node_modules/@loopwright/state/dist/pages.js +41 -0
- package/node_modules/@loopwright/state/dist/receipts.d.ts +33 -0
- package/node_modules/@loopwright/state/dist/receipts.js +97 -0
- package/node_modules/@loopwright/state/dist/schema.d.ts +28 -0
- package/node_modules/@loopwright/state/dist/schema.js +41 -0
- package/node_modules/@loopwright/state/dist/settlement.d.ts +10 -0
- package/node_modules/@loopwright/state/dist/settlement.js +129 -0
- package/node_modules/@loopwright/state/dist/store.d.ts +52 -0
- package/node_modules/@loopwright/state/dist/store.js +100 -0
- package/node_modules/@loopwright/state/dist/types.d.ts +315 -0
- package/node_modules/@loopwright/state/dist/types.js +1 -0
- package/node_modules/@loopwright/state/package.json +12 -0
- package/node_modules/@loopwright/taskpack/dist/baseline-align.d.ts +195 -0
- package/node_modules/@loopwright/taskpack/dist/baseline-align.js +1847 -0
- package/node_modules/@loopwright/taskpack/dist/digests.d.ts +61 -0
- package/node_modules/@loopwright/taskpack/dist/digests.js +715 -0
- package/node_modules/@loopwright/taskpack/dist/index.d.ts +18 -0
- package/node_modules/@loopwright/taskpack/dist/index.js +17 -0
- package/node_modules/@loopwright/taskpack/dist/models-config.d.ts +112 -0
- package/node_modules/@loopwright/taskpack/dist/models-config.js +1026 -0
- package/node_modules/@loopwright/taskpack/dist/output-format.d.ts +28 -0
- package/node_modules/@loopwright/taskpack/dist/output-format.js +157 -0
- package/node_modules/@loopwright/taskpack/dist/preflight.d.ts +130 -0
- package/node_modules/@loopwright/taskpack/dist/preflight.js +1497 -0
- package/node_modules/@loopwright/taskpack/dist/qualification.d.ts +23 -0
- package/node_modules/@loopwright/taskpack/dist/qualification.js +120 -0
- package/node_modules/@loopwright/taskpack/dist/sandbox.d.ts +121 -0
- package/node_modules/@loopwright/taskpack/dist/sandbox.js +2642 -0
- package/node_modules/@loopwright/taskpack/dist/schema.d.ts +197 -0
- package/node_modules/@loopwright/taskpack/dist/schema.js +4189 -0
- package/node_modules/@loopwright/taskpack/dist/scrubber.d.ts +47 -0
- package/node_modules/@loopwright/taskpack/dist/scrubber.js +283 -0
- package/node_modules/@loopwright/taskpack/dist/suite.d.ts +124 -0
- package/node_modules/@loopwright/taskpack/dist/suite.js +3256 -0
- package/node_modules/@loopwright/taskpack/dist/taskpack.d.ts +154 -0
- package/node_modules/@loopwright/taskpack/dist/taskpack.js +3634 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey-memory.d.ts +122 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey-memory.js +483 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey.d.ts +437 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey.js +7335 -0
- package/node_modules/@loopwright/taskpack/dist/types.d.ts +1274 -0
- package/node_modules/@loopwright/taskpack/dist/types.js +99 -0
- package/node_modules/@loopwright/taskpack/dist/upstreams.d.ts +261 -0
- package/node_modules/@loopwright/taskpack/dist/upstreams.js +2242 -0
- package/node_modules/@loopwright/taskpack/dist/yaml.d.ts +18 -0
- package/node_modules/@loopwright/taskpack/dist/yaml.js +167 -0
- package/node_modules/@loopwright/taskpack/package.json +12 -0
- package/node_modules/@loopwright/taskpack-runner/dist/compile-taskpack.d.ts +137 -0
- package/node_modules/@loopwright/taskpack-runner/dist/compile-taskpack.js +474 -0
- package/node_modules/@loopwright/taskpack-runner/dist/corpus.d.ts +8 -0
- package/node_modules/@loopwright/taskpack-runner/dist/corpus.js +129 -0
- package/node_modules/@loopwright/taskpack-runner/dist/index.d.ts +13 -0
- package/node_modules/@loopwright/taskpack-runner/dist/index.js +7 -0
- package/node_modules/@loopwright/taskpack-runner/dist/intake.d.ts +149 -0
- package/node_modules/@loopwright/taskpack-runner/dist/intake.js +135 -0
- package/node_modules/@loopwright/taskpack-runner/dist/parity.d.ts +130 -0
- package/node_modules/@loopwright/taskpack-runner/dist/parity.js +927 -0
- package/node_modules/@loopwright/taskpack-runner/dist/python-bridge.d.ts +68 -0
- package/node_modules/@loopwright/taskpack-runner/dist/python-bridge.js +517 -0
- package/node_modules/@loopwright/taskpack-runner/dist/service.d.ts +149 -0
- package/node_modules/@loopwright/taskpack-runner/dist/service.js +1796 -0
- package/node_modules/@loopwright/taskpack-runner/dist/types.d.ts +29 -0
- package/node_modules/@loopwright/taskpack-runner/dist/types.js +11 -0
- package/node_modules/@loopwright/taskpack-runner/package.json +12 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/README.md +77 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/docs/support-records.md +57 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/docs/supported-runners.md +98 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/manifest.json +205 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/expand_matrix.sh +273 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/matrix.yaml +280 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/resolve_dockerfile.sh +24 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pyproject.toml +46 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/runtime_runner/runner.py.json +5270 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/discovery/legacy-support.md +86 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/github/service.py +401 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/proposals/analysis.json +95 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/proposals/ready.json +109 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_assemble.py +263 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_check_draft.py +333 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_checks.py +1099 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_discovery.py +817 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_proposal.py +658 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_publish.py +987 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_summary.py +107 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/agent.py +610 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/assemble.py +84 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/check_draft.py +94 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/checks.py +1002 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/discovery.py +789 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/model.py +557 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/progress.py +174 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/analysis.md +40 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/proposal.md +65 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/repair.md +17 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/proposal.py +903 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/publish.py +997 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/summary.py +131 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/tool-versions.json +133 -0
- package/node_modules/package-lock.json +3025 -0
- package/package-lock.json +3025 -0
- package/package.json +52 -4
|
@@ -0,0 +1,1500 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { constants, lstatSync, realpathSync } from 'node:fs';
|
|
4
|
+
import { chmod, lstat, mkdir, open, readdir, realpath, unlink } from 'node:fs/promises';
|
|
5
|
+
import { dirname, isAbsolute, join, resolve, sep } from 'node:path';
|
|
6
|
+
import { VERIFIER_ARTIFACT_LIMITS, } from '@loopwright/core';
|
|
7
|
+
import { assertNoSymlinkAncestors, hasLoneSurrogate, parseStrictJsonBytes, } from './config.js';
|
|
8
|
+
import { MAX_CAS_CHUNK_BYTES } from './relay-server.js';
|
|
9
|
+
import { HardwareRunnerError, } from './types.js';
|
|
10
|
+
export const TRUSTED_NVIDIA_SMI_PATHS = Object.freeze([
|
|
11
|
+
'/usr/bin/nvidia-smi',
|
|
12
|
+
'/usr/local/bin/nvidia-smi',
|
|
13
|
+
'/bin/nvidia-smi',
|
|
14
|
+
]);
|
|
15
|
+
export const TRUSTED_ROCM_SMI_PATHS = Object.freeze([
|
|
16
|
+
'/opt/rocm/bin/rocm-smi',
|
|
17
|
+
'/usr/bin/rocm-smi',
|
|
18
|
+
'/usr/local/bin/rocm-smi',
|
|
19
|
+
]);
|
|
20
|
+
export const TRUSTED_ROCMINFO_PATHS = Object.freeze([
|
|
21
|
+
'/opt/rocm/bin/rocminfo',
|
|
22
|
+
'/usr/bin/rocminfo',
|
|
23
|
+
'/usr/local/bin/rocminfo',
|
|
24
|
+
]);
|
|
25
|
+
export const TRUSTED_NPU_SMI_PATHS = Object.freeze([
|
|
26
|
+
'/usr/local/Ascend/driver/tools/npu-smi',
|
|
27
|
+
'/usr/local/sbin/npu-smi',
|
|
28
|
+
'/usr/local/bin/npu-smi',
|
|
29
|
+
'/usr/bin/npu-smi',
|
|
30
|
+
]);
|
|
31
|
+
export const WORKLOAD_TREE_DOMAIN = 'loopwright.dev/held-out-workload-tree/v1';
|
|
32
|
+
const MAX_PROBE_OUTPUT_BYTES = 262_144;
|
|
33
|
+
const DEFAULT_PROBE_TIMEOUT_MS = 15_000;
|
|
34
|
+
const WORKLOAD_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
35
|
+
const PRINTABLE_ASCII_RE = /^[\x20-\x7E]+$/;
|
|
36
|
+
const CONTROL_CHAR_RE = /[\r\n\t\p{C}]/u;
|
|
37
|
+
const ANSI_ESC_PREFIX = String.fromCharCode(0x1b) + '[';
|
|
38
|
+
function stripAnsiSequences(text) {
|
|
39
|
+
if (!text.includes(ANSI_ESC_PREFIX))
|
|
40
|
+
return text;
|
|
41
|
+
let out = '';
|
|
42
|
+
let idx = 0;
|
|
43
|
+
while (idx < text.length) {
|
|
44
|
+
if (text.startsWith(ANSI_ESC_PREFIX, idx)) {
|
|
45
|
+
let end = idx + 2;
|
|
46
|
+
while (end < text.length && /[0-9;]/.test(text[end]))
|
|
47
|
+
end += 1;
|
|
48
|
+
if (end < text.length && /[A-Za-z]/.test(text[end])) {
|
|
49
|
+
idx = end + 1;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
out += text[idx];
|
|
54
|
+
idx += 1;
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
export const ROOT_OWNED_SYSTEM_PREFIXES = Object.freeze([
|
|
59
|
+
'/usr/',
|
|
60
|
+
'/bin/',
|
|
61
|
+
'/sbin/',
|
|
62
|
+
'/lib/',
|
|
63
|
+
'/lib64/',
|
|
64
|
+
'/opt/',
|
|
65
|
+
'/etc/alternatives/',
|
|
66
|
+
]);
|
|
67
|
+
function compareUtf16(a, b) {
|
|
68
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
69
|
+
}
|
|
70
|
+
function sanitizePrintableField(raw, fallback, maxLen = 128, asciiOnly = false) {
|
|
71
|
+
const collapsed = raw.replace(/[\r\n\t]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
72
|
+
if (collapsed.length === 0 || hasLoneSurrogate(collapsed) || CONTROL_CHAR_RE.test(collapsed)) {
|
|
73
|
+
return fallback;
|
|
74
|
+
}
|
|
75
|
+
const clipped = collapsed.length > maxLen ? collapsed.slice(0, maxLen).trim() : collapsed;
|
|
76
|
+
if (clipped.length === 0)
|
|
77
|
+
return fallback;
|
|
78
|
+
if (asciiOnly && !PRINTABLE_ASCII_RE.test(clipped)) {
|
|
79
|
+
return fallback;
|
|
80
|
+
}
|
|
81
|
+
return clipped;
|
|
82
|
+
}
|
|
83
|
+
function isUnderRootSystemPrefix(candidatePath) {
|
|
84
|
+
return ROOT_OWNED_SYSTEM_PREFIXES.some(prefix => candidatePath === prefix.replace(/\/$/, '')
|
|
85
|
+
|| candidatePath.startsWith(prefix.endsWith('/') ? prefix : `${prefix}/`));
|
|
86
|
+
}
|
|
87
|
+
function isInsideOrEqualPath(candidatePath, rootPath) {
|
|
88
|
+
return candidatePath === rootPath || candidatePath.startsWith(rootPath.endsWith(sep) ? rootPath : `${rootPath}${sep}`);
|
|
89
|
+
}
|
|
90
|
+
function validateCleanExecutablePathString(binaryPath, label) {
|
|
91
|
+
if (typeof binaryPath !== 'string'
|
|
92
|
+
|| binaryPath.length === 0
|
|
93
|
+
|| binaryPath.length > 1024
|
|
94
|
+
|| /[\0\r\n]/.test(binaryPath)
|
|
95
|
+
|| hasLoneSurrogate(binaryPath)
|
|
96
|
+
|| !isAbsolute(binaryPath)) {
|
|
97
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable path must be a clean absolute path`);
|
|
98
|
+
}
|
|
99
|
+
return resolve(binaryPath);
|
|
100
|
+
}
|
|
101
|
+
function inspectTrustedChainSync(targetPath, stopAtTestRoot, label) {
|
|
102
|
+
let cursor = resolve(targetPath);
|
|
103
|
+
let depth = 0;
|
|
104
|
+
let leafStat = null;
|
|
105
|
+
let hasSymlinkInChain = false;
|
|
106
|
+
const hostUid = typeof process.getuid === 'function' ? process.getuid() : null;
|
|
107
|
+
while (true) {
|
|
108
|
+
if (++depth > 64) {
|
|
109
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable path exceeds directory depth limit`);
|
|
110
|
+
}
|
|
111
|
+
let st;
|
|
112
|
+
try {
|
|
113
|
+
st = lstatSync(cursor);
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
if (err?.code === 'ENOENT') {
|
|
117
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable "${targetPath}" is not installed`);
|
|
118
|
+
}
|
|
119
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `failed to inspect ${label} executable "${targetPath}"`);
|
|
120
|
+
}
|
|
121
|
+
if (leafStat === null) {
|
|
122
|
+
leafStat = st;
|
|
123
|
+
}
|
|
124
|
+
else if (!st.isSymbolicLink() && !st.isDirectory()) {
|
|
125
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable ancestor "${cursor}" is not a directory`);
|
|
126
|
+
}
|
|
127
|
+
if (st.isSymbolicLink()) {
|
|
128
|
+
hasSymlinkInChain = true;
|
|
129
|
+
}
|
|
130
|
+
const inScopedTestTree = stopAtTestRoot !== null && isInsideOrEqualPath(cursor, stopAtTestRoot);
|
|
131
|
+
if (hostUid !== null) {
|
|
132
|
+
if (inScopedTestTree) {
|
|
133
|
+
if (st.uid !== 0 && st.uid !== hostUid) {
|
|
134
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable path component "${cursor}" has untrusted owner uid ${st.uid}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (stopAtTestRoot === null && st.uid !== 0) {
|
|
138
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable path component "${cursor}" must be owned by root (uid 0)`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (stopAtTestRoot === null || inScopedTestTree) {
|
|
142
|
+
if (!st.isSymbolicLink() && (st.mode & 0o022) !== 0) {
|
|
143
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable path component "${cursor}" must not be group or world writable`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (stopAtTestRoot !== null && cursor === stopAtTestRoot) {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
const parent = dirname(cursor);
|
|
150
|
+
if (parent === cursor)
|
|
151
|
+
break;
|
|
152
|
+
cursor = parent;
|
|
153
|
+
}
|
|
154
|
+
return { leafStat: leafStat, hasSymlinkInChain };
|
|
155
|
+
}
|
|
156
|
+
function assertLeafExecutableSafe(leafStat, targetPath, scopedTestMode, label) {
|
|
157
|
+
if (!leafStat.isFile() || leafStat.isSymbolicLink() || (leafStat.mode & 0o111) === 0) {
|
|
158
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable "${targetPath}" is not an executable regular file`);
|
|
159
|
+
}
|
|
160
|
+
if ((leafStat.mode & 0o022) !== 0) {
|
|
161
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable "${targetPath}" must not be group or world writable`);
|
|
162
|
+
}
|
|
163
|
+
const hostUid = typeof process.getuid === 'function' ? process.getuid() : null;
|
|
164
|
+
if (hostUid !== null) {
|
|
165
|
+
if (!scopedTestMode && leafStat.uid !== 0) {
|
|
166
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable "${targetPath}" must be owned by root (uid 0)`);
|
|
167
|
+
}
|
|
168
|
+
if (leafStat.uid !== 0 && (leafStat.mode & 0o200) !== 0) {
|
|
169
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `non-root ${label} executable "${targetPath}" must not be owner-writable (expected mode 0555 or 0500)`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Synchronously verify that `binaryPath` is an element of `trustedAllowlist`, is owned by `uid === 0`
|
|
175
|
+
* across every path component and resolved symlink target, has no group/world-writable file or parent
|
|
176
|
+
* directory, and resolves to an executable regular file.
|
|
177
|
+
*/
|
|
178
|
+
export function verifyTrustedSystemExecutableSync(binaryPath, trustedAllowlist, options = {}, label = 'hardware probe') {
|
|
179
|
+
const normalized = validateCleanExecutablePathString(binaryPath, label);
|
|
180
|
+
if (!trustedAllowlist.includes(normalized)) {
|
|
181
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `untrusted ${label} executable "${binaryPath}"`);
|
|
182
|
+
}
|
|
183
|
+
const allowRootSymlink = options.allowRootSystemSymlink !== false;
|
|
184
|
+
const scopedTestRoot = options._testOnlyTrustedRoot !== undefined ? resolve(options._testOnlyTrustedRoot) : null;
|
|
185
|
+
if (scopedTestRoot !== null && !isInsideOrEqualPath(normalized, scopedTestRoot)) {
|
|
186
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable "${normalized}" is outside _testOnlyTrustedRoot`);
|
|
187
|
+
}
|
|
188
|
+
const launcherCheck = inspectTrustedChainSync(normalized, scopedTestRoot, label);
|
|
189
|
+
if (launcherCheck.hasSymlinkInChain) {
|
|
190
|
+
if (!allowRootSymlink || scopedTestRoot !== null) {
|
|
191
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable "${normalized}" must not traverse symlinks`);
|
|
192
|
+
}
|
|
193
|
+
if (!isUnderRootSystemPrefix(normalized)) {
|
|
194
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `symlinked ${label} executable "${normalized}" is outside trusted system prefixes`);
|
|
195
|
+
}
|
|
196
|
+
let resolvedReal;
|
|
197
|
+
try {
|
|
198
|
+
resolvedReal = realpathSync(normalized);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `failed to resolve symlinked ${label} executable "${normalized}"`);
|
|
202
|
+
}
|
|
203
|
+
if (!isUnderRootSystemPrefix(resolvedReal)) {
|
|
204
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable "${normalized}" resolves outside trusted system prefixes`);
|
|
205
|
+
}
|
|
206
|
+
const targetCheck = inspectTrustedChainSync(resolvedReal, null, label);
|
|
207
|
+
if (targetCheck.hasSymlinkInChain) {
|
|
208
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `resolved ${label} executable "${resolvedReal}" still contains symlinks`);
|
|
209
|
+
}
|
|
210
|
+
assertLeafExecutableSafe(targetCheck.leafStat, resolvedReal, false, label);
|
|
211
|
+
return resolvedReal;
|
|
212
|
+
}
|
|
213
|
+
if (scopedTestRoot === null && !isUnderRootSystemPrefix(normalized)) {
|
|
214
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `${label} executable "${normalized}" is outside trusted system prefixes`);
|
|
215
|
+
}
|
|
216
|
+
assertLeafExecutableSafe(launcherCheck.leafStat, normalized, scopedTestRoot !== null, label);
|
|
217
|
+
return normalized;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Verify that `binaryPath` is an element of `trustedAllowlist`, is owned by root (`uid === 0`) across
|
|
221
|
+
* both launcher path and resolved target, has no group/world-writable components, and is an executable
|
|
222
|
+
* regular file.
|
|
223
|
+
*/
|
|
224
|
+
export async function verifyTrustedProbeExecutable(binaryPath, trustedAllowlist, options = {}) {
|
|
225
|
+
return verifyTrustedSystemExecutableSync(binaryPath, trustedAllowlist, options, 'hardware probe');
|
|
226
|
+
}
|
|
227
|
+
async function resolveFirstTrustedProbeExecutable(explicitPath, trustedAllowlist, verifier) {
|
|
228
|
+
if (explicitPath !== undefined) {
|
|
229
|
+
return verifier(explicitPath, trustedAllowlist);
|
|
230
|
+
}
|
|
231
|
+
let lastError = null;
|
|
232
|
+
for (const candidate of trustedAllowlist) {
|
|
233
|
+
try {
|
|
234
|
+
return await verifier(candidate, trustedAllowlist);
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
lastError = err;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (lastError instanceof HardwareRunnerError) {
|
|
241
|
+
throw lastError;
|
|
242
|
+
}
|
|
243
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `none of the trusted hardware probe binaries are available (${trustedAllowlist.join(', ')})`);
|
|
244
|
+
}
|
|
245
|
+
export const defaultProbeCommandRunner = (executablePath, args, options) => {
|
|
246
|
+
if (!isAbsolute(executablePath) || /[\0\r\n]/.test(executablePath)) {
|
|
247
|
+
return Promise.reject(new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'probe executable must be an absolute path'));
|
|
248
|
+
}
|
|
249
|
+
for (const arg of args) {
|
|
250
|
+
if (typeof arg !== 'string' || /[\0\r\n]/.test(arg)) {
|
|
251
|
+
return Promise.reject(new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'probe argument contains forbidden characters'));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (options.signal?.aborted) {
|
|
255
|
+
return Promise.reject(new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'hardware probe aborted'));
|
|
256
|
+
}
|
|
257
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
258
|
+
const child = execFile(executablePath, [...args], {
|
|
259
|
+
shell: false,
|
|
260
|
+
cwd: '/',
|
|
261
|
+
env: {
|
|
262
|
+
PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
|
263
|
+
LANG: 'C',
|
|
264
|
+
LC_ALL: 'C',
|
|
265
|
+
},
|
|
266
|
+
timeout: options.timeoutMs,
|
|
267
|
+
maxBuffer: MAX_PROBE_OUTPUT_BYTES,
|
|
268
|
+
killSignal: 'SIGKILL',
|
|
269
|
+
windowsHide: true,
|
|
270
|
+
}, (error, stdout, stderr) => {
|
|
271
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
272
|
+
if (options.signal?.aborted) {
|
|
273
|
+
rejectPromise(new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'hardware probe aborted'));
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (error !== null) {
|
|
277
|
+
const errno = error;
|
|
278
|
+
if (errno.killed || errno.code === 'ETIMEDOUT' || errno.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') {
|
|
279
|
+
rejectPromise(new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `hardware probe failed or exceeded bounds: ${error.message}`));
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (typeof errno.code === 'number') {
|
|
283
|
+
resolvePromise({
|
|
284
|
+
exitCode: errno.code,
|
|
285
|
+
stdout: typeof stdout === 'string' ? stdout : String(stdout ?? ''),
|
|
286
|
+
stderr: typeof stderr === 'string' ? stderr : String(stderr ?? ''),
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
rejectPromise(new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `hardware probe spawn error: ${error.message}`));
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
resolvePromise({
|
|
294
|
+
exitCode: 0,
|
|
295
|
+
stdout: typeof stdout === 'string' ? stdout : String(stdout ?? ''),
|
|
296
|
+
stderr: typeof stderr === 'string' ? stderr : String(stderr ?? ''),
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
const onAbort = () => {
|
|
300
|
+
child.kill('SIGKILL');
|
|
301
|
+
};
|
|
302
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
function normalizeCudaComputeCap(rawCap, preferredAccelerator) {
|
|
306
|
+
const trimmed = rawCap.trim().toLowerCase();
|
|
307
|
+
const smMatch = /^sm_([0-9]{2,3}[a-z]?)$/.exec(trimmed);
|
|
308
|
+
if (smMatch !== null) {
|
|
309
|
+
return `sm_${smMatch[1]}`;
|
|
310
|
+
}
|
|
311
|
+
const dottedMatch = /^([0-9]{1,2})\.([0-9])([a-z]?)$/.exec(trimmed);
|
|
312
|
+
if (dottedMatch === null) {
|
|
313
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `unable to parse CUDA compute capability "${rawCap}"`);
|
|
314
|
+
}
|
|
315
|
+
const baseDigits = `${dottedMatch[1]}${dottedMatch[2]}`;
|
|
316
|
+
const explicitSuffix = dottedMatch[3];
|
|
317
|
+
if (explicitSuffix.length > 0) {
|
|
318
|
+
return `sm_${baseDigits}${explicitSuffix}`;
|
|
319
|
+
}
|
|
320
|
+
// Hopper (9.0 -> sm_90a) and Blackwell (10.0 -> sm_100a) expose architecture-accelerated
|
|
321
|
+
// instruction targets via the 'a' suffix while nvidia-smi reports numeric major.minor.
|
|
322
|
+
if (preferredAccelerator !== undefined
|
|
323
|
+
&& (baseDigits === '90' || baseDigits === '100' || baseDigits === '120')
|
|
324
|
+
&& preferredAccelerator === `sm_${baseDigits}a`) {
|
|
325
|
+
return preferredAccelerator;
|
|
326
|
+
}
|
|
327
|
+
return `sm_${baseDigits}`;
|
|
328
|
+
}
|
|
329
|
+
function resolveAllocatedDeviceIndices(requestedCount, explicitIndices, availableIndices, totalHostCount) {
|
|
330
|
+
if (explicitIndices !== undefined) {
|
|
331
|
+
if (explicitIndices.length < 1 || explicitIndices.length > 64) {
|
|
332
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'allocatedDeviceIndices must contain 1..64 device indices');
|
|
333
|
+
}
|
|
334
|
+
if (requestedCount !== undefined && explicitIndices.length !== requestedCount) {
|
|
335
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `allocatedDeviceIndices count (${explicitIndices.length}) does not match requested deviceCount (${requestedCount})`);
|
|
336
|
+
}
|
|
337
|
+
const seen = new Set();
|
|
338
|
+
const validated = [];
|
|
339
|
+
for (const idx of explicitIndices) {
|
|
340
|
+
if (!Number.isSafeInteger(idx) || Object.is(idx, -0) || idx < 0 || idx >= 64) {
|
|
341
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `invalid allocated device index ${String(idx)}`);
|
|
342
|
+
}
|
|
343
|
+
if (seen.has(idx)) {
|
|
344
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `duplicate allocated device index ${idx}`);
|
|
345
|
+
}
|
|
346
|
+
if (!availableIndices.has(idx)) {
|
|
347
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `physical host has ${totalHostCount} devices, fewer than required or missing allocated device index ${idx}`);
|
|
348
|
+
}
|
|
349
|
+
seen.add(idx);
|
|
350
|
+
validated.push(idx);
|
|
351
|
+
}
|
|
352
|
+
return Object.freeze(validated);
|
|
353
|
+
}
|
|
354
|
+
if (requestedCount !== undefined) {
|
|
355
|
+
if (!Number.isSafeInteger(requestedCount) || Object.is(requestedCount, -0) || requestedCount < 1 || requestedCount > 64) {
|
|
356
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `invalid requested deviceCount (${String(requestedCount)})`);
|
|
357
|
+
}
|
|
358
|
+
if (totalHostCount < requestedCount) {
|
|
359
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `physical host has ${totalHostCount} devices, fewer than required ${requestedCount}`);
|
|
360
|
+
}
|
|
361
|
+
const sortedAvailable = [...availableIndices].sort((a, b) => a - b);
|
|
362
|
+
if (sortedAvailable.length < requestedCount) {
|
|
363
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `physical host has ${sortedAvailable.length} devices, fewer than required ${requestedCount}`);
|
|
364
|
+
}
|
|
365
|
+
return Object.freeze(sortedAvailable.slice(0, requestedCount));
|
|
366
|
+
}
|
|
367
|
+
const allSorted = [...availableIndices].sort((a, b) => a - b);
|
|
368
|
+
if (allSorted.length < 1 || allSorted.length > 64) {
|
|
369
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `invalid host accelerator device count (${allSorted.length})`);
|
|
370
|
+
}
|
|
371
|
+
return Object.freeze(allSorted);
|
|
372
|
+
}
|
|
373
|
+
function parsePeerMatrixBlocks(rawText, prefixWord) {
|
|
374
|
+
if (rawText.trim().length === 0)
|
|
375
|
+
return [];
|
|
376
|
+
const cleaned = stripAnsiSequences(rawText);
|
|
377
|
+
const headerTokenPattern = new RegExp(`^${prefixWord}(\\d+)$`, 'i');
|
|
378
|
+
const rowPrefixPattern = new RegExp(`^${prefixWord}(\\d+)$`, 'i');
|
|
379
|
+
const blocks = [];
|
|
380
|
+
let current = null;
|
|
381
|
+
const tryParseHeaderColumns = (parts) => {
|
|
382
|
+
let startIdx = -1;
|
|
383
|
+
if (parts.length >= 2 && headerTokenPattern.test(parts[0]) && headerTokenPattern.test(parts[1])) {
|
|
384
|
+
startIdx = 0;
|
|
385
|
+
}
|
|
386
|
+
else if (parts.length >= 3
|
|
387
|
+
&& !headerTokenPattern.test(parts[0])
|
|
388
|
+
&& headerTokenPattern.test(parts[1])
|
|
389
|
+
&& headerTokenPattern.test(parts[2])) {
|
|
390
|
+
startIdx = 1;
|
|
391
|
+
}
|
|
392
|
+
if (startIdx < 0)
|
|
393
|
+
return null;
|
|
394
|
+
const colIds = [];
|
|
395
|
+
const seen = new Set();
|
|
396
|
+
let endedDeviceCols = false;
|
|
397
|
+
for (let i = startIdx; i < parts.length; i += 1) {
|
|
398
|
+
const hm = headerTokenPattern.exec(parts[i]);
|
|
399
|
+
if (hm !== null) {
|
|
400
|
+
if (endedDeviceCols) {
|
|
401
|
+
// Discontiguous device header tokens after non-device columns are ambiguous.
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
const id = Number.parseInt(hm[1], 10);
|
|
405
|
+
if (!Number.isSafeInteger(id) || id < 0 || id >= 64 || seen.has(id)) {
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
seen.add(id);
|
|
409
|
+
colIds.push(id);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
endedDeviceCols = true;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return colIds.length >= 2 ? colIds : null;
|
|
416
|
+
};
|
|
417
|
+
for (const rawLine of cleaned.split(/\r?\n/)) {
|
|
418
|
+
const line = rawLine.trim();
|
|
419
|
+
if (line.length === 0)
|
|
420
|
+
continue;
|
|
421
|
+
const parts = line.split(/\s+/);
|
|
422
|
+
// Always inspect for a column header row BEFORE data-row matching so a trimmed
|
|
423
|
+
// header like "GPU3 GPU2 GPU1 GPU0 CPU Affinity" never masquerades as data row GPU3.
|
|
424
|
+
if ((parts.length >= 2 && headerTokenPattern.test(parts[0]) && headerTokenPattern.test(parts[1]))
|
|
425
|
+
|| (parts.length >= 3 && !headerTokenPattern.test(parts[0]) && headerTokenPattern.test(parts[1]) && headerTokenPattern.test(parts[2]))) {
|
|
426
|
+
const parsedCols = tryParseHeaderColumns(parts);
|
|
427
|
+
if (parsedCols === null) {
|
|
428
|
+
if (current !== null)
|
|
429
|
+
current.invalid = true;
|
|
430
|
+
current = { colIds: [], rowsByDevice: new Map(), invalid: true };
|
|
431
|
+
blocks.push(current);
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
current = { colIds: parsedCols, rowsByDevice: new Map(), invalid: false };
|
|
435
|
+
blocks.push(current);
|
|
436
|
+
}
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
if (current === null) {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
const rowMatch = rowPrefixPattern.exec(parts[0]);
|
|
443
|
+
if (rowMatch === null || parts.length < 2) {
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
const rowDevIdx = Number.parseInt(rowMatch[1], 10);
|
|
447
|
+
if (!Number.isSafeInteger(rowDevIdx) || rowDevIdx < 0 || rowDevIdx >= 64) {
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
if (current.rowsByDevice.has(rowDevIdx)) {
|
|
451
|
+
current.invalid = true;
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
current.rowsByDevice.set(rowDevIdx, parts.slice(1));
|
|
455
|
+
}
|
|
456
|
+
return blocks;
|
|
457
|
+
}
|
|
458
|
+
function extractMappedPeerMatrixTopology(rawText, prefixWord, allocatedIndices, mapCellToken) {
|
|
459
|
+
const k = allocatedIndices.length;
|
|
460
|
+
if (k < 2 || rawText.trim().length === 0)
|
|
461
|
+
return undefined;
|
|
462
|
+
const blocks = parsePeerMatrixBlocks(rawText, prefixWord);
|
|
463
|
+
if (blocks.length === 0)
|
|
464
|
+
return undefined;
|
|
465
|
+
const expectedPairs = (k * (k - 1)) / 2;
|
|
466
|
+
let resolvedTopology;
|
|
467
|
+
for (const block of blocks) {
|
|
468
|
+
if (block.invalid || block.colIds.length < k || block.rowsByDevice.size < k) {
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
// Require every allocated device ID to appear unambiguously in BOTH column headers and row labels,
|
|
472
|
+
// with a self-diagonal ('X' or 'SELF') confirming row/column alignment.
|
|
473
|
+
let alignmentValid = true;
|
|
474
|
+
for (const devIdx of allocatedIndices) {
|
|
475
|
+
const selfCol = block.colIds.indexOf(devIdx);
|
|
476
|
+
const selfRow = block.rowsByDevice.get(devIdx);
|
|
477
|
+
if (selfCol < 0 || selfRow === undefined || selfCol >= selfRow.length) {
|
|
478
|
+
alignmentValid = false;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
const diag = selfRow[selfCol]?.trim().toUpperCase();
|
|
482
|
+
if (diag !== 'X' && diag !== 'SELF') {
|
|
483
|
+
alignmentValid = false;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (!alignmentValid) {
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
const observedPairs = new Set();
|
|
491
|
+
const mappedTokens = [];
|
|
492
|
+
let pairsValid = true;
|
|
493
|
+
for (let i = 0; i < k && pairsValid; i += 1) {
|
|
494
|
+
const devA = allocatedIndices[i];
|
|
495
|
+
const rowA = block.rowsByDevice.get(devA);
|
|
496
|
+
const colA = block.colIds.indexOf(devA);
|
|
497
|
+
for (let j = i + 1; j < k; j += 1) {
|
|
498
|
+
const devB = allocatedIndices[j];
|
|
499
|
+
const rowB = block.rowsByDevice.get(devB);
|
|
500
|
+
const colB = block.colIds.indexOf(devB);
|
|
501
|
+
if (colB < 0 || colB >= rowA.length || colA < 0 || colA >= rowB.length) {
|
|
502
|
+
pairsValid = false;
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
const tokAB = rowA[colB]?.trim() ?? '';
|
|
506
|
+
const tokBA = rowB[colA]?.trim() ?? '';
|
|
507
|
+
if (!tokAB
|
|
508
|
+
|| !tokBA
|
|
509
|
+
|| tokAB.toUpperCase() === 'X'
|
|
510
|
+
|| tokAB.toUpperCase() === 'SELF'
|
|
511
|
+
|| tokBA.toUpperCase() === 'X'
|
|
512
|
+
|| tokBA.toUpperCase() === 'SELF') {
|
|
513
|
+
pairsValid = false;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
const mappedAB = mapCellToken(tokAB);
|
|
517
|
+
const mappedBA = mapCellToken(tokBA);
|
|
518
|
+
if (!mappedAB || !mappedBA) {
|
|
519
|
+
pairsValid = false;
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
observedPairs.add(`${Math.min(devA, devB)}:${Math.max(devA, devB)}`);
|
|
523
|
+
mappedTokens.push(mappedAB, mappedBA);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
if (!pairsValid || observedPairs.size !== expectedPairs || mappedTokens.length === 0) {
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
const unique = [...new Set(mappedTokens)].sort(compareUtf16);
|
|
530
|
+
const candidateTopo = unique.length === 1 ? unique[0] : unique.join('+');
|
|
531
|
+
if (resolvedTopology !== undefined && resolvedTopology !== candidateTopo) {
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
534
|
+
resolvedTopology = candidateTopo;
|
|
535
|
+
}
|
|
536
|
+
return resolvedTopology;
|
|
537
|
+
}
|
|
538
|
+
function observeNvidiaTopology(topoOutput, allocatedIndices) {
|
|
539
|
+
return extractMappedPeerMatrixTopology(topoOutput, 'GPU', allocatedIndices, tok => {
|
|
540
|
+
const upper = tok.toUpperCase();
|
|
541
|
+
if (/^NV\d+$/.test(upper))
|
|
542
|
+
return upper.toLowerCase();
|
|
543
|
+
if (upper === 'NVB' || upper === 'NVLINK')
|
|
544
|
+
return 'nvlink';
|
|
545
|
+
if (upper === 'PIX' || upper === 'PXB' || upper === 'PHB' || upper === 'NODE' || upper === 'SYS') {
|
|
546
|
+
return upper.toLowerCase();
|
|
547
|
+
}
|
|
548
|
+
return sanitizePrintableField(tok.toLowerCase(), '', 32, true);
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
export function parseNvidiaSmiOutput(queryOutput, detailOutput = '', options = {}) {
|
|
552
|
+
if (typeof queryOutput !== 'string' || queryOutput.trim().length === 0) {
|
|
553
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'empty nvidia-smi output');
|
|
554
|
+
}
|
|
555
|
+
const lines = queryOutput
|
|
556
|
+
.split(/\r?\n/)
|
|
557
|
+
.map(line => line.trim())
|
|
558
|
+
.filter(line => line.length > 0);
|
|
559
|
+
if (lines.length === 0 || lines.length > 64) {
|
|
560
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'nvidia-smi reported an invalid number of GPU rows');
|
|
561
|
+
}
|
|
562
|
+
const availableIndices = new Set(Array.from({ length: lines.length }, (_, idx) => idx));
|
|
563
|
+
const allocatedIndices = resolveAllocatedDeviceIndices(options.allocatedDeviceCount, options.allocatedDeviceIndices, availableIndices, lines.length);
|
|
564
|
+
let deviceModel = '';
|
|
565
|
+
let accelerator = '';
|
|
566
|
+
let driverVersion = '';
|
|
567
|
+
let sliced = false;
|
|
568
|
+
let csvRuntimeVersion;
|
|
569
|
+
const rowClockLocks = [];
|
|
570
|
+
for (const idx of allocatedIndices) {
|
|
571
|
+
const line = lines[idx];
|
|
572
|
+
const cols = line.split(',').map(part => part.trim());
|
|
573
|
+
if (cols.length < 3) {
|
|
574
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'malformed nvidia-smi CSV row');
|
|
575
|
+
}
|
|
576
|
+
const rowModel = sanitizePrintableField(cols[0], '', 128, false);
|
|
577
|
+
const rowCap = normalizeCudaComputeCap(cols[1], options.preferredAccelerator);
|
|
578
|
+
const rowDriver = sanitizePrintableField(cols[2], '', 128, false);
|
|
579
|
+
if (!rowModel || !rowDriver) {
|
|
580
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'nvidia-smi row missing GPU model or driver version');
|
|
581
|
+
}
|
|
582
|
+
if (!deviceModel)
|
|
583
|
+
deviceModel = rowModel;
|
|
584
|
+
if (!accelerator) {
|
|
585
|
+
accelerator = rowCap;
|
|
586
|
+
}
|
|
587
|
+
else if (accelerator !== rowCap) {
|
|
588
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `heterogeneous CUDA compute capabilities (${accelerator} vs ${rowCap}) in single probe`);
|
|
589
|
+
}
|
|
590
|
+
if (!driverVersion)
|
|
591
|
+
driverVersion = rowDriver;
|
|
592
|
+
const migCol = (cols[3] ?? '').toLowerCase();
|
|
593
|
+
if (migCol === 'enabled' || /\bmig\b/i.test(rowModel)) {
|
|
594
|
+
sliced = true;
|
|
595
|
+
}
|
|
596
|
+
if (cols[4] !== undefined && cols[4].length > 0 && cols[4].toLowerCase() !== 'n/a') {
|
|
597
|
+
const cleanedRt = sanitizePrintableField(cols[4], '', 128, false);
|
|
598
|
+
if (cleanedRt)
|
|
599
|
+
csvRuntimeVersion ??= cleanedRt;
|
|
600
|
+
}
|
|
601
|
+
if (cols[5] !== undefined && cols[5].length > 0) {
|
|
602
|
+
const lockVal = cols[5].toLowerCase();
|
|
603
|
+
if (lockVal === 'locked' || lockVal === 'active' || lockVal === 'enabled')
|
|
604
|
+
rowClockLocks.push('locked');
|
|
605
|
+
else if (lockVal === 'unlocked' || lockVal === 'idle' || lockVal === 'disabled')
|
|
606
|
+
rowClockLocks.push('unlocked');
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
// Never scrape host driver "CUDA Version :" from nvidia-smi -q as container/workload runtimeVersion.
|
|
610
|
+
const runtimeCandidate = options.measuredRuntimeVersion ?? csvRuntimeVersion ?? '';
|
|
611
|
+
const runtimeVersion = runtimeCandidate.length > 0 ? runtimeCandidate : 'cuda-unknown';
|
|
612
|
+
let clockLockMode = 'unknown';
|
|
613
|
+
if (rowClockLocks.length === allocatedIndices.length) {
|
|
614
|
+
clockLockMode = rowClockLocks.every(v => v === 'locked') ? 'locked' : 'unlocked';
|
|
615
|
+
}
|
|
616
|
+
else if (rowClockLocks.includes('unlocked')) {
|
|
617
|
+
clockLockMode = 'unlocked';
|
|
618
|
+
}
|
|
619
|
+
else if (detailOutput.trim().length > 0
|
|
620
|
+
&& (options.detailScopedToAllocated === true || allocatedIndices.length === lines.length)) {
|
|
621
|
+
if (/\bClocks\s*:\s*Unlocked\b/i.test(detailOutput)) {
|
|
622
|
+
clockLockMode = 'unlocked';
|
|
623
|
+
}
|
|
624
|
+
else if (/Locked\s+Clocks[\s\S]{0,160}?(?:Active|Locked\s*:\s*Yes)/i.test(detailOutput)
|
|
625
|
+
|| /\bClocks\s*:\s*Locked\b/i.test(detailOutput)) {
|
|
626
|
+
clockLockMode = 'locked';
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
const detectedTopology = observeNvidiaTopology(options.topoOutput ?? '', allocatedIndices);
|
|
630
|
+
return Object.freeze({
|
|
631
|
+
vendor: 'nvidia',
|
|
632
|
+
deviceModel,
|
|
633
|
+
accelerator,
|
|
634
|
+
isolationMode: sliced ? 'sliced' : 'whole_device',
|
|
635
|
+
deviceCount: allocatedIndices.length,
|
|
636
|
+
driverVersion,
|
|
637
|
+
runtimeVersion: sanitizePrintableField(runtimeVersion, 'cuda-unknown', 128, false),
|
|
638
|
+
...(detectedTopology !== undefined ? { topology: detectedTopology } : {}),
|
|
639
|
+
clockLockMode,
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
function parseRocminfoAgents(rocminfoOutput) {
|
|
643
|
+
const architectures = [];
|
|
644
|
+
const models = [];
|
|
645
|
+
if (!rocminfoOutput.trim().length) {
|
|
646
|
+
return { architectures, models };
|
|
647
|
+
}
|
|
648
|
+
const runtimeMatch = /ROCm(?:\s+Runtime)?\s+Version\s*:\s*([^\r\n]+)/i.exec(rocminfoOutput);
|
|
649
|
+
const blocks = rocminfoOutput.split(/\*{5,}\s*\r?\n\s*Agent\s+\d+\s*\r?\n\s*\*{5,}/i);
|
|
650
|
+
const candidateBlocks = blocks.length > 1 ? blocks.slice(1) : [rocminfoOutput];
|
|
651
|
+
for (const block of candidateBlocks) {
|
|
652
|
+
const typeMatch = /^\s*Device Type\s*:\s*([A-Za-z0-9_-]+)/im.exec(block);
|
|
653
|
+
if (typeMatch !== null && typeMatch[1].toUpperCase() !== 'GPU') {
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
const nameMatches = [...block.matchAll(/^\s*Name\s*:\s*(gfx[0-9a-z_]+)\s*$/gim)];
|
|
657
|
+
const mktMatch = /^\s*Marketing Name\s*:\s*(.+)$/im.exec(block);
|
|
658
|
+
if (nameMatches.length > 0) {
|
|
659
|
+
const gfx = nameMatches[0][1].toLowerCase();
|
|
660
|
+
architectures.push(gfx);
|
|
661
|
+
const cleanModel = mktMatch !== null ? sanitizePrintableField(mktMatch[1], '', 128, false) : '';
|
|
662
|
+
models.push(cleanModel);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
const runtimeVal = runtimeMatch?.[1] !== undefined
|
|
666
|
+
? sanitizePrintableField(runtimeMatch[1], '', 128, false)
|
|
667
|
+
: '';
|
|
668
|
+
return {
|
|
669
|
+
architectures,
|
|
670
|
+
models,
|
|
671
|
+
...(runtimeVal.length > 0 ? { runtimeVersion: runtimeVal } : {}),
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
function observeRocmTopology(topoOutput, allocatedIndices) {
|
|
675
|
+
if (allocatedIndices.length < 2 || topoOutput.trim().length === 0)
|
|
676
|
+
return undefined;
|
|
677
|
+
const matrixTopo = extractMappedPeerMatrixTopology(topoOutput, 'GPU', allocatedIndices, tok => {
|
|
678
|
+
const upper = tok.toUpperCase();
|
|
679
|
+
if (upper.startsWith('XGMI'))
|
|
680
|
+
return 'xgmi';
|
|
681
|
+
if (upper.startsWith('PCIE') || upper === 'PHB' || upper === 'PXB' || upper === 'PIX' || upper === 'SYS') {
|
|
682
|
+
return 'pcie';
|
|
683
|
+
}
|
|
684
|
+
return '';
|
|
685
|
+
});
|
|
686
|
+
if (matrixTopo !== undefined) {
|
|
687
|
+
return matrixTopo;
|
|
688
|
+
}
|
|
689
|
+
const allocatedSet = new Set(allocatedIndices);
|
|
690
|
+
const expectedPairs = (allocatedIndices.length * (allocatedIndices.length - 1)) / 2;
|
|
691
|
+
const observedPairs = new Map();
|
|
692
|
+
const cleaned = stripAnsiSequences(topoOutput);
|
|
693
|
+
const pairRe = /\bGPU\[(\d+)\]\s*-\s*GPU\[(\d+)\]\s*:\s*(?:Link\s+Type\s*:\s*)?(XGMI|PCIE)\b/gi;
|
|
694
|
+
for (const m of cleaned.matchAll(pairRe)) {
|
|
695
|
+
const a = Number.parseInt(m[1], 10);
|
|
696
|
+
const b = Number.parseInt(m[2], 10);
|
|
697
|
+
if (!allocatedSet.has(a) || !allocatedSet.has(b) || a === b)
|
|
698
|
+
continue;
|
|
699
|
+
const key = `${Math.min(a, b)}:${Math.max(a, b)}`;
|
|
700
|
+
const linkType = m[3].toLowerCase();
|
|
701
|
+
const prev = observedPairs.get(key);
|
|
702
|
+
if (prev !== undefined && prev !== linkType) {
|
|
703
|
+
return undefined;
|
|
704
|
+
}
|
|
705
|
+
observedPairs.set(key, linkType);
|
|
706
|
+
}
|
|
707
|
+
if (observedPairs.size !== expectedPairs) {
|
|
708
|
+
return undefined;
|
|
709
|
+
}
|
|
710
|
+
const uniq = [...new Set(observedPairs.values())].sort(compareUtf16);
|
|
711
|
+
return uniq.length === 1 ? uniq[0] : uniq.join('+');
|
|
712
|
+
}
|
|
713
|
+
export function parseRocmSmiOutput(rocmSmiOutput, rocminfoOutput = '', options = {}) {
|
|
714
|
+
const combined = `${rocmSmiOutput}\n${rocminfoOutput}`.trim();
|
|
715
|
+
if (combined.length === 0) {
|
|
716
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'empty rocm-smi and rocminfo output');
|
|
717
|
+
}
|
|
718
|
+
const rocminfo = parseRocminfoAgents(rocminfoOutput);
|
|
719
|
+
const cardsByIndex = new Map();
|
|
720
|
+
let driverVersion = '';
|
|
721
|
+
let runtimeVersion = rocminfo.runtimeVersion ?? '';
|
|
722
|
+
const getOrCreateCard = (idx) => {
|
|
723
|
+
let rec = cardsByIndex.get(idx);
|
|
724
|
+
if (!rec) {
|
|
725
|
+
rec = { deviceModel: '', gfxArch: '', sliced: false, clockLockMode: 'unknown' };
|
|
726
|
+
cardsByIndex.set(idx, rec);
|
|
727
|
+
}
|
|
728
|
+
return rec;
|
|
729
|
+
};
|
|
730
|
+
const trimmedSmi = rocmSmiOutput.trim();
|
|
731
|
+
if (trimmedSmi.startsWith('{')) {
|
|
732
|
+
const parsed = parseStrictJsonBytes(Buffer.from(trimmedSmi, 'utf8'), MAX_PROBE_OUTPUT_BYTES, 'RUNNER_SANDBOX_FAILED', '/rocmSmi');
|
|
733
|
+
if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
734
|
+
const root = parsed;
|
|
735
|
+
for (const key of Object.keys(root).sort()) {
|
|
736
|
+
if (!Object.hasOwn(root, key))
|
|
737
|
+
continue;
|
|
738
|
+
const val = root[key];
|
|
739
|
+
if (val === null || typeof val !== 'object' || Array.isArray(val))
|
|
740
|
+
continue;
|
|
741
|
+
const entry = val;
|
|
742
|
+
if (key === 'system') {
|
|
743
|
+
for (const sysKey of Object.keys(entry)) {
|
|
744
|
+
if (!Object.hasOwn(entry, sysKey) || typeof entry[sysKey] !== 'string')
|
|
745
|
+
continue;
|
|
746
|
+
const lowerKey = sysKey.toLowerCase();
|
|
747
|
+
if (lowerKey.includes('driver')) {
|
|
748
|
+
driverVersion = sanitizePrintableField(entry[sysKey], driverVersion, 128, false);
|
|
749
|
+
}
|
|
750
|
+
else if (lowerKey.includes('rocm') || lowerKey.includes('hip')) {
|
|
751
|
+
runtimeVersion = sanitizePrintableField(entry[sysKey], runtimeVersion, 128, false);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
continue;
|
|
755
|
+
}
|
|
756
|
+
const cardMatch = /^(?:card|gpu)(\d+)$/i.exec(key);
|
|
757
|
+
if (cardMatch !== null) {
|
|
758
|
+
const cardIdx = Number.parseInt(cardMatch[1], 10);
|
|
759
|
+
if (!Number.isSafeInteger(cardIdx) || cardIdx < 0 || cardIdx >= 64)
|
|
760
|
+
continue;
|
|
761
|
+
const card = getOrCreateCard(cardIdx);
|
|
762
|
+
for (const cardKey of Object.keys(entry)) {
|
|
763
|
+
if (!Object.hasOwn(entry, cardKey) || typeof entry[cardKey] !== 'string')
|
|
764
|
+
continue;
|
|
765
|
+
const rawVal = entry[cardKey];
|
|
766
|
+
const lowerKey = cardKey.toLowerCase();
|
|
767
|
+
if ((!card.deviceModel || /^0x[0-9a-f]+$/i.test(card.deviceModel))
|
|
768
|
+
&& (lowerKey.includes('card series') || lowerKey.includes('product name') || lowerKey.includes('marketing name') || lowerKey === 'card model')) {
|
|
769
|
+
const candidateModel = sanitizePrintableField(rawVal, '', 128, false);
|
|
770
|
+
if (candidateModel && (!/^0x[0-9a-f]+$/i.test(candidateModel) || !card.deviceModel)) {
|
|
771
|
+
card.deviceModel = candidateModel;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (lowerKey.includes('gfx') || lowerKey.includes('target')) {
|
|
775
|
+
const gfxMatch = /\b(gfx[0-9a-z_]+)\b/i.exec(rawVal);
|
|
776
|
+
if (gfxMatch !== null && !card.gfxArch) {
|
|
777
|
+
card.gfxArch = gfxMatch[1].toLowerCase();
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
if (lowerKey.includes('partition') && /\b(?:cpx|tpx|qpx|dpx|spx_sliced|sliced)\b/i.test(rawVal)) {
|
|
781
|
+
card.sliced = true;
|
|
782
|
+
}
|
|
783
|
+
if (lowerKey.includes('performance level') || lowerKey.includes('perf level')) {
|
|
784
|
+
if (/\b(?:manual|locked|profile_peak)\b/i.test(rawVal))
|
|
785
|
+
card.clockLockMode = 'locked';
|
|
786
|
+
else if (/\bauto\b/i.test(rawVal))
|
|
787
|
+
card.clockLockMode = 'unlocked';
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
else if (trimmedSmi.length > 0) {
|
|
795
|
+
for (const rawLine of trimmedSmi.split(/\r?\n/)) {
|
|
796
|
+
const line = rawLine.trim();
|
|
797
|
+
if (!line)
|
|
798
|
+
continue;
|
|
799
|
+
const drvMatch = /^Driver\s+version\s*:\s*(.+)$/i.exec(line);
|
|
800
|
+
if (drvMatch !== null) {
|
|
801
|
+
driverVersion = sanitizePrintableField(drvMatch[1], driverVersion, 128, false);
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
const rocmVerMatch = /^ROCm\s+version\s*:\s*(.+)$/i.exec(line);
|
|
805
|
+
if (rocmVerMatch !== null) {
|
|
806
|
+
runtimeVersion = sanitizePrintableField(rocmVerMatch[1], runtimeVersion, 128, false);
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
const prefixMatch = /^(?:GPU|card)\[(\d+)\]\s*:\s*(.+)$/i.exec(line);
|
|
810
|
+
const cardIdx = prefixMatch !== null ? Number.parseInt(prefixMatch[1], 10) : 0;
|
|
811
|
+
const body = prefixMatch !== null ? prefixMatch[2] : line;
|
|
812
|
+
if (prefixMatch === null && !/(?:Card Series|Product Name|Marketing Name|GFX Version|Compute Partition|Performance Level)\s*:/i.test(body)) {
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
if (!Number.isSafeInteger(cardIdx) || cardIdx < 0 || cardIdx >= 64)
|
|
816
|
+
continue;
|
|
817
|
+
const card = getOrCreateCard(cardIdx);
|
|
818
|
+
const inlineDrv = /^Driver\s+version\s*:\s*(.+)$/i.exec(body);
|
|
819
|
+
if (inlineDrv !== null) {
|
|
820
|
+
driverVersion = sanitizePrintableField(inlineDrv[1], driverVersion, 128, false);
|
|
821
|
+
}
|
|
822
|
+
const inlineRocm = /^ROCm\s+version\s*:\s*(.+)$/i.exec(body);
|
|
823
|
+
if (inlineRocm !== null) {
|
|
824
|
+
runtimeVersion = sanitizePrintableField(inlineRocm[1], runtimeVersion, 128, false);
|
|
825
|
+
}
|
|
826
|
+
const seriesMatch = /(?:Card Series|Card series|Product Name|Marketing Name)\s*:\s*(.+)$/i.exec(body);
|
|
827
|
+
if (seriesMatch !== null && !card.deviceModel) {
|
|
828
|
+
card.deviceModel = sanitizePrintableField(seriesMatch[1], '', 128, false);
|
|
829
|
+
}
|
|
830
|
+
const gfxMatch = /\b(gfx[0-9a-z_]+)\b/i.exec(body);
|
|
831
|
+
if (gfxMatch !== null && !card.gfxArch) {
|
|
832
|
+
card.gfxArch = gfxMatch[1].toLowerCase();
|
|
833
|
+
}
|
|
834
|
+
if (/\bCompute Partition\s*:\s*(?:CPX|TPX|QPX|DPX)\b/i.test(body)) {
|
|
835
|
+
card.sliced = true;
|
|
836
|
+
}
|
|
837
|
+
if (/Performance Level\s*:\s*manual/i.test(body)) {
|
|
838
|
+
card.clockLockMode = 'locked';
|
|
839
|
+
}
|
|
840
|
+
else if (/Performance Level\s*:\s*auto/i.test(body)) {
|
|
841
|
+
card.clockLockMode = 'unlocked';
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
const availableIndices = new Set();
|
|
846
|
+
for (const idx of cardsByIndex.keys())
|
|
847
|
+
availableIndices.add(idx);
|
|
848
|
+
for (let idx = 0; idx < rocminfo.architectures.length; idx += 1)
|
|
849
|
+
availableIndices.add(idx);
|
|
850
|
+
if (availableIndices.size < 1 || availableIndices.size > 64) {
|
|
851
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'unable to determine AMD GPU gfx architecture from rocm-smi/rocminfo');
|
|
852
|
+
}
|
|
853
|
+
const allocatedIndices = resolveAllocatedDeviceIndices(options.allocatedDeviceCount, options.allocatedDeviceIndices, availableIndices, availableIndices.size);
|
|
854
|
+
let deviceModel = '';
|
|
855
|
+
let gfxArch = '';
|
|
856
|
+
let sliced = false;
|
|
857
|
+
const allocatedLocks = [];
|
|
858
|
+
for (const idx of allocatedIndices) {
|
|
859
|
+
const card = cardsByIndex.get(idx);
|
|
860
|
+
const agentArch = rocminfo.architectures[idx];
|
|
861
|
+
const agentModel = rocminfo.models[idx];
|
|
862
|
+
const resolvedArch = card?.gfxArch || agentArch || '';
|
|
863
|
+
if (!resolvedArch || !/^gfx[0-9a-z_]{1,60}$/.test(resolvedArch)) {
|
|
864
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'unable to determine AMD GPU gfx architecture from rocm-smi/rocminfo');
|
|
865
|
+
}
|
|
866
|
+
if (!gfxArch) {
|
|
867
|
+
gfxArch = resolvedArch;
|
|
868
|
+
}
|
|
869
|
+
else if (gfxArch !== resolvedArch) {
|
|
870
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `heterogeneous ROCm GPU architectures (${gfxArch} vs ${resolvedArch}) in single probe`);
|
|
871
|
+
}
|
|
872
|
+
const cardModel = card?.deviceModel ?? '';
|
|
873
|
+
const candidateModel = (!cardModel || /^0x[0-9a-f]+$/i.test(cardModel)) && agentModel ? agentModel : cardModel;
|
|
874
|
+
if (!deviceModel && candidateModel) {
|
|
875
|
+
deviceModel = candidateModel;
|
|
876
|
+
}
|
|
877
|
+
if (card?.sliced) {
|
|
878
|
+
sliced = true;
|
|
879
|
+
}
|
|
880
|
+
if (card?.clockLockMode === 'locked' || card?.clockLockMode === 'unlocked') {
|
|
881
|
+
allocatedLocks.push(card.clockLockMode);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
if (!deviceModel) {
|
|
885
|
+
deviceModel = `AMD ROCm GPU (${gfxArch})`;
|
|
886
|
+
}
|
|
887
|
+
if (!driverVersion) {
|
|
888
|
+
driverVersion = 'rocm-driver-unknown';
|
|
889
|
+
}
|
|
890
|
+
const effectiveRuntime = options.measuredRuntimeVersion
|
|
891
|
+
?? (options.ignoreHostRuntimeVersion === true ? '' : runtimeVersion);
|
|
892
|
+
const finalRuntime = effectiveRuntime || 'rocm-unknown';
|
|
893
|
+
const clockLockMode = allocatedLocks.length === allocatedIndices.length
|
|
894
|
+
? (allocatedLocks.every(v => v === 'locked') ? 'locked' : 'unlocked')
|
|
895
|
+
: allocatedLocks.includes('unlocked')
|
|
896
|
+
? 'unlocked'
|
|
897
|
+
: 'unknown';
|
|
898
|
+
const detectedTopology = observeRocmTopology(options.topoOutput ?? trimmedSmi, allocatedIndices);
|
|
899
|
+
return Object.freeze({
|
|
900
|
+
vendor: 'amd',
|
|
901
|
+
deviceModel,
|
|
902
|
+
accelerator: gfxArch,
|
|
903
|
+
isolationMode: sliced ? 'sliced' : 'whole_device',
|
|
904
|
+
deviceCount: allocatedIndices.length,
|
|
905
|
+
driverVersion: sanitizePrintableField(driverVersion, 'rocm-driver-unknown', 128, false),
|
|
906
|
+
runtimeVersion: sanitizePrintableField(finalRuntime, 'rocm-unknown', 128, false),
|
|
907
|
+
...(detectedTopology !== undefined ? { topology: detectedTopology } : {}),
|
|
908
|
+
clockLockMode,
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
function normalizeAscendAccelerator(rawChip, preferredAccelerator) {
|
|
912
|
+
const compact = rawChip.replace(/^ascend[\s_-]*/i, '').trim().toLowerCase();
|
|
913
|
+
if (/^910b[0-9a-z]*$/.test(compact)) {
|
|
914
|
+
const exact = `ascend_${compact}`;
|
|
915
|
+
if (preferredAccelerator !== undefined && preferredAccelerator === exact) {
|
|
916
|
+
return exact;
|
|
917
|
+
}
|
|
918
|
+
return 'ascend_910b';
|
|
919
|
+
}
|
|
920
|
+
if (/^910[a-z0-9]*$/.test(compact)) {
|
|
921
|
+
return `ascend_${compact}`;
|
|
922
|
+
}
|
|
923
|
+
if (/^310p[0-9a-z]*$/.test(compact)) {
|
|
924
|
+
return preferredAccelerator === `ascend_${compact}` ? preferredAccelerator : 'ascend_310p';
|
|
925
|
+
}
|
|
926
|
+
const safe = compact.replace(/[^a-z0-9_]+/g, '_').replace(/^_+|_+$/g, '');
|
|
927
|
+
if (!safe) {
|
|
928
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `unable to normalize Ascend chip name "${rawChip}"`);
|
|
929
|
+
}
|
|
930
|
+
return safe.startsWith('ascend_') ? safe : `ascend_${safe}`;
|
|
931
|
+
}
|
|
932
|
+
function observeAscendTopology(topoOutput, allocatedIndices) {
|
|
933
|
+
if (allocatedIndices.length < 2 || topoOutput.trim().length === 0)
|
|
934
|
+
return undefined;
|
|
935
|
+
return extractMappedPeerMatrixTopology(topoOutput, 'NPU', allocatedIndices, tok => {
|
|
936
|
+
const upper = tok.toUpperCase();
|
|
937
|
+
if (upper.startsWith('HCCS'))
|
|
938
|
+
return 'hccs';
|
|
939
|
+
if (upper === 'PIX' || upper === 'PXB' || upper === 'PHB' || upper === 'SYS' || upper === 'PCIE') {
|
|
940
|
+
return 'pcie';
|
|
941
|
+
}
|
|
942
|
+
return '';
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
const ASCEND_VNPU_MARKER_RE = /\b(?:vNPU|Vir[0-9]{2})\b/i;
|
|
946
|
+
export function parseNpuSmiOutput(npuSmiOutput, options = {}) {
|
|
947
|
+
if (typeof npuSmiOutput !== 'string' || npuSmiOutput.trim().length === 0) {
|
|
948
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'empty npu-smi output');
|
|
949
|
+
}
|
|
950
|
+
let driverVersion = '';
|
|
951
|
+
const bannerVer = /(?:Version|Driver Version)\s*:\s*([0-9A-Za-z._-]+)/i.exec(npuSmiOutput);
|
|
952
|
+
if (bannerVer !== null) {
|
|
953
|
+
driverVersion = sanitizePrintableField(bannerVer[1], '', 128, false);
|
|
954
|
+
}
|
|
955
|
+
const cannMatch = /CANN(?:\s+Version)?\s*:\s*([0-9A-Za-z._-]+)/i.exec(npuSmiOutput);
|
|
956
|
+
const cannCleaned = cannMatch !== null ? sanitizePrintableField(cannMatch[1], '', 120, false) : '';
|
|
957
|
+
const effectiveRt = options.measuredRuntimeVersion
|
|
958
|
+
?? (options.ignoreHostRuntimeVersion === true ? '' : (cannCleaned.length > 0 ? `cann-${cannCleaned}` : ''));
|
|
959
|
+
const runtimeVersion = effectiveRt.length > 0 ? effectiveRt : 'cann-unknown';
|
|
960
|
+
const npuRecords = new Map();
|
|
961
|
+
let currentTableNpuIdx = null;
|
|
962
|
+
let hasTableRecords = false;
|
|
963
|
+
for (const rawLine of npuSmiOutput.split(/\r?\n/)) {
|
|
964
|
+
const trimmed = rawLine.trim();
|
|
965
|
+
if (trimmed.length === 0)
|
|
966
|
+
continue;
|
|
967
|
+
if (/^\+[-=+:|]+\+$/.test(trimmed)) {
|
|
968
|
+
currentTableNpuIdx = null;
|
|
969
|
+
continue;
|
|
970
|
+
}
|
|
971
|
+
const tableChipMatch = /^\|\s*(\d+)\s+(?:Ascend[\s_-]*)?([0-9]{3}[A-Za-z0-9_-]*)\b([^|]*)\|/i.exec(trimmed);
|
|
972
|
+
if (tableChipMatch !== null) {
|
|
973
|
+
const npuIdx = Number.parseInt(tableChipMatch[1], 10);
|
|
974
|
+
if (Number.isSafeInteger(npuIdx) && npuIdx >= 0 && npuIdx < 64) {
|
|
975
|
+
hasTableRecords = true;
|
|
976
|
+
currentTableNpuIdx = npuIdx;
|
|
977
|
+
const prev = npuRecords.get(npuIdx);
|
|
978
|
+
npuRecords.set(npuIdx, {
|
|
979
|
+
chip: tableChipMatch[2],
|
|
980
|
+
sliced: (prev?.sliced ?? false) || ASCEND_VNPU_MARKER_RE.test(trimmed),
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
if (hasTableRecords && ASCEND_VNPU_MARKER_RE.test(trimmed)) {
|
|
986
|
+
const explicitRowIdx = /^\|\s*(\d+)\b/.exec(trimmed);
|
|
987
|
+
if (explicitRowIdx !== null) {
|
|
988
|
+
const rowIdx = Number.parseInt(explicitRowIdx[1], 10);
|
|
989
|
+
if (currentTableNpuIdx !== null && npuRecords.has(currentTableNpuIdx)) {
|
|
990
|
+
npuRecords.get(currentTableNpuIdx).sliced = true;
|
|
991
|
+
}
|
|
992
|
+
else if (npuRecords.has(rowIdx)) {
|
|
993
|
+
npuRecords.get(rowIdx).sliced = true;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
else if (currentTableNpuIdx !== null && npuRecords.has(currentTableNpuIdx)) {
|
|
997
|
+
npuRecords.get(currentTableNpuIdx).sliced = true;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
if (npuRecords.size === 0) {
|
|
1002
|
+
let seqIdx = 0;
|
|
1003
|
+
let pendingExplicitIdx = null;
|
|
1004
|
+
let activeKvIdx = null;
|
|
1005
|
+
for (const rawLine of npuSmiOutput.split(/\r?\n/)) {
|
|
1006
|
+
const trimmed = rawLine.trim();
|
|
1007
|
+
if (trimmed.length === 0)
|
|
1008
|
+
continue;
|
|
1009
|
+
const idMatch = /^(?:NPU\s+ID|NPU)\s*:\s*(\d+)\s*$/i.exec(trimmed);
|
|
1010
|
+
if (idMatch !== null) {
|
|
1011
|
+
const parsedId = Number.parseInt(idMatch[1], 10);
|
|
1012
|
+
if (Number.isSafeInteger(parsedId) && parsedId >= 0 && parsedId < 64) {
|
|
1013
|
+
pendingExplicitIdx = parsedId;
|
|
1014
|
+
activeKvIdx = parsedId;
|
|
1015
|
+
}
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
const kvChip = /Chip\s+Name\s*:\s*(?:Ascend[\s_-]*)?([0-9]{3}[A-Za-z0-9_-]*)/i.exec(trimmed);
|
|
1019
|
+
if (kvChip !== null) {
|
|
1020
|
+
const targetIdx = pendingExplicitIdx !== null && !npuRecords.has(pendingExplicitIdx)
|
|
1021
|
+
? pendingExplicitIdx
|
|
1022
|
+
: seqIdx;
|
|
1023
|
+
pendingExplicitIdx = null;
|
|
1024
|
+
if (targetIdx >= seqIdx) {
|
|
1025
|
+
seqIdx = targetIdx + 1;
|
|
1026
|
+
}
|
|
1027
|
+
if (targetIdx < 64) {
|
|
1028
|
+
activeKvIdx = targetIdx;
|
|
1029
|
+
npuRecords.set(targetIdx, {
|
|
1030
|
+
chip: kvChip[1],
|
|
1031
|
+
sliced: ASCEND_VNPU_MARKER_RE.test(trimmed),
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
continue;
|
|
1035
|
+
}
|
|
1036
|
+
if (ASCEND_VNPU_MARKER_RE.test(trimmed) && activeKvIdx !== null && npuRecords.has(activeKvIdx)) {
|
|
1037
|
+
npuRecords.get(activeKvIdx).sliced = true;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
if (npuRecords.size === 0 || npuRecords.size > 64) {
|
|
1042
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'unable to parse NPU devices from npu-smi output');
|
|
1043
|
+
}
|
|
1044
|
+
const allocatedIndices = resolveAllocatedDeviceIndices(options.allocatedDeviceCount, options.allocatedDeviceIndices, new Set(npuRecords.keys()), npuRecords.size);
|
|
1045
|
+
const primaryChip = npuRecords.get(allocatedIndices[0]).chip;
|
|
1046
|
+
const accelerator = normalizeAscendAccelerator(primaryChip, options.preferredAccelerator);
|
|
1047
|
+
let sliced = false;
|
|
1048
|
+
for (const idx of allocatedIndices) {
|
|
1049
|
+
const rec = npuRecords.get(idx);
|
|
1050
|
+
const norm = normalizeAscendAccelerator(rec.chip, options.preferredAccelerator);
|
|
1051
|
+
if (norm !== accelerator) {
|
|
1052
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `heterogeneous Ascend NPU accelerators (${accelerator} vs ${norm}) in single probe`);
|
|
1053
|
+
}
|
|
1054
|
+
if (rec.sliced) {
|
|
1055
|
+
sliced = true;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
const deviceModel = sanitizePrintableField(primaryChip.toLowerCase().startsWith('ascend') ? primaryChip : `Huawei Ascend ${primaryChip}`, `Huawei Ascend ${accelerator}`, 128, false);
|
|
1059
|
+
if (!driverVersion) {
|
|
1060
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'npu-smi output missing driver version');
|
|
1061
|
+
}
|
|
1062
|
+
const detectedTopology = observeAscendTopology(options.topoOutput ?? '', allocatedIndices);
|
|
1063
|
+
return Object.freeze({
|
|
1064
|
+
vendor: 'huawei',
|
|
1065
|
+
deviceModel,
|
|
1066
|
+
accelerator,
|
|
1067
|
+
isolationMode: sliced ? 'sliced' : 'whole_device',
|
|
1068
|
+
deviceCount: allocatedIndices.length,
|
|
1069
|
+
driverVersion,
|
|
1070
|
+
runtimeVersion,
|
|
1071
|
+
...(detectedTopology !== undefined ? { topology: detectedTopology } : {}),
|
|
1072
|
+
clockLockMode: 'unknown',
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
async function streamWorkloadFileNoFollow(filePath, maxFileBytes, snapshotDestPath, signal) {
|
|
1076
|
+
const noFollow = 'O_NOFOLLOW' in constants ? constants.O_NOFOLLOW : 0;
|
|
1077
|
+
const before = await lstat(filePath).catch((err) => {
|
|
1078
|
+
if (err?.code === 'ELOOP') {
|
|
1079
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'symlink forbidden inside held_out_workloads');
|
|
1080
|
+
}
|
|
1081
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'failed to inspect held_out_workloads file');
|
|
1082
|
+
});
|
|
1083
|
+
if (before.isSymbolicLink() || !before.isFile()) {
|
|
1084
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'held_out_workloads entry must be a regular non-symlink file');
|
|
1085
|
+
}
|
|
1086
|
+
if (before.nlink !== 1) {
|
|
1087
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'hardlinked files are forbidden inside held_out_workloads');
|
|
1088
|
+
}
|
|
1089
|
+
if (before.size > maxFileBytes) {
|
|
1090
|
+
throw new HardwareRunnerError('PAYLOAD_TOO_LARGE', `held_out_workloads file exceeds ${maxFileBytes} bytes`);
|
|
1091
|
+
}
|
|
1092
|
+
let srcHandle;
|
|
1093
|
+
try {
|
|
1094
|
+
srcHandle = await open(filePath, constants.O_RDONLY | noFollow);
|
|
1095
|
+
}
|
|
1096
|
+
catch (err) {
|
|
1097
|
+
if (err?.code === 'ELOOP') {
|
|
1098
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'symlink detected while opening held_out_workloads file');
|
|
1099
|
+
}
|
|
1100
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'failed to open held_out_workloads file safely');
|
|
1101
|
+
}
|
|
1102
|
+
let dstHandle = null;
|
|
1103
|
+
let dstCreated = false;
|
|
1104
|
+
try {
|
|
1105
|
+
const opened = await srcHandle.stat();
|
|
1106
|
+
if (!opened.isFile()
|
|
1107
|
+
|| opened.isSymbolicLink()
|
|
1108
|
+
|| opened.nlink !== 1
|
|
1109
|
+
|| opened.dev !== before.dev
|
|
1110
|
+
|| opened.ino !== before.ino
|
|
1111
|
+
|| opened.size !== before.size) {
|
|
1112
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'held_out_workloads file identity changed during open');
|
|
1113
|
+
}
|
|
1114
|
+
const sealedMode = (opened.mode & 0o111) !== 0 ? 0o500 : 0o400;
|
|
1115
|
+
if (snapshotDestPath !== null) {
|
|
1116
|
+
dstHandle = await open(snapshotDestPath, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | noFollow, 0o600);
|
|
1117
|
+
dstCreated = true;
|
|
1118
|
+
}
|
|
1119
|
+
const hasher = createHash('sha256');
|
|
1120
|
+
const chunkBuf = Buffer.allocUnsafe(Math.min(MAX_CAS_CHUNK_BYTES, Math.max(1, opened.size)));
|
|
1121
|
+
let offset = 0;
|
|
1122
|
+
while (offset < opened.size) {
|
|
1123
|
+
if (signal?.aborted) {
|
|
1124
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'workload digest computation aborted');
|
|
1125
|
+
}
|
|
1126
|
+
const toRead = Math.min(chunkBuf.byteLength, opened.size - offset);
|
|
1127
|
+
const { bytesRead } = await srcHandle.read(chunkBuf, 0, toRead, offset);
|
|
1128
|
+
if (bytesRead <= 0)
|
|
1129
|
+
break;
|
|
1130
|
+
const slice = chunkBuf.subarray(0, bytesRead);
|
|
1131
|
+
hasher.update(slice);
|
|
1132
|
+
if (dstHandle !== null) {
|
|
1133
|
+
let writtenOff = 0;
|
|
1134
|
+
while (writtenOff < slice.byteLength) {
|
|
1135
|
+
const { bytesWritten } = await dstHandle.write(slice, writtenOff, slice.byteLength - writtenOff);
|
|
1136
|
+
if (bytesWritten <= 0) {
|
|
1137
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'short write while snapshotting held-out workload');
|
|
1138
|
+
}
|
|
1139
|
+
writtenOff += bytesWritten;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
offset += bytesRead;
|
|
1143
|
+
}
|
|
1144
|
+
const extra = await srcHandle.read(chunkBuf, 0, 1, offset);
|
|
1145
|
+
const after = await srcHandle.stat();
|
|
1146
|
+
if (extra.bytesRead !== 0
|
|
1147
|
+
|| offset !== opened.size
|
|
1148
|
+
|| after.dev !== opened.dev
|
|
1149
|
+
|| after.ino !== opened.ino
|
|
1150
|
+
|| after.size !== opened.size
|
|
1151
|
+
|| after.nlink !== 1
|
|
1152
|
+
|| after.mtimeMs !== opened.mtimeMs
|
|
1153
|
+
|| after.ctimeMs !== opened.ctimeMs) {
|
|
1154
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'held_out_workloads file mutated during hashing');
|
|
1155
|
+
}
|
|
1156
|
+
if (dstHandle !== null) {
|
|
1157
|
+
await dstHandle.chmod(sealedMode);
|
|
1158
|
+
await dstHandle.sync();
|
|
1159
|
+
const dstStat = await dstHandle.stat();
|
|
1160
|
+
if (!dstStat.isFile()
|
|
1161
|
+
|| dstStat.isSymbolicLink()
|
|
1162
|
+
|| dstStat.nlink !== 1
|
|
1163
|
+
|| dstStat.size !== offset
|
|
1164
|
+
|| (dstStat.mode & 0o7777) !== sealedMode) {
|
|
1165
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'workload snapshot file failed mode/nlink sealing');
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
return { sha256: hasher.digest('hex'), bytes: offset };
|
|
1169
|
+
}
|
|
1170
|
+
catch (err) {
|
|
1171
|
+
if (dstHandle !== null) {
|
|
1172
|
+
await dstHandle.close().catch(() => { });
|
|
1173
|
+
dstHandle = null;
|
|
1174
|
+
}
|
|
1175
|
+
if (dstCreated && snapshotDestPath !== null) {
|
|
1176
|
+
await unlink(snapshotDestPath).catch(() => { });
|
|
1177
|
+
}
|
|
1178
|
+
throw err;
|
|
1179
|
+
}
|
|
1180
|
+
finally {
|
|
1181
|
+
if (dstHandle !== null) {
|
|
1182
|
+
await dstHandle.close();
|
|
1183
|
+
}
|
|
1184
|
+
await srcHandle.close();
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
async function processHeldOutWorkloadTree(heldOutWorkloadsDir, heldOutWorkloadId, snapshotDestDir, options = {}) {
|
|
1188
|
+
if (typeof heldOutWorkloadId !== 'string'
|
|
1189
|
+
|| !WORKLOAD_ID_RE.test(heldOutWorkloadId)
|
|
1190
|
+
|| heldOutWorkloadId === '.'
|
|
1191
|
+
|| heldOutWorkloadId === '..') {
|
|
1192
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'invalid heldOutWorkloadId', '/heldOutWorkloadId');
|
|
1193
|
+
}
|
|
1194
|
+
const baseDir = resolve(heldOutWorkloadsDir);
|
|
1195
|
+
await assertNoSymlinkAncestors(baseDir, {
|
|
1196
|
+
checkLeaf: true,
|
|
1197
|
+
code: 'ARTIFACT_INVALID',
|
|
1198
|
+
diagPath: '/heldOutWorkloadsDir',
|
|
1199
|
+
});
|
|
1200
|
+
const workloadDir = join(baseDir, heldOutWorkloadId);
|
|
1201
|
+
await assertNoSymlinkAncestors(workloadDir, {
|
|
1202
|
+
checkLeaf: true,
|
|
1203
|
+
code: 'ARTIFACT_INVALID',
|
|
1204
|
+
diagPath: '/heldOutWorkloadId',
|
|
1205
|
+
});
|
|
1206
|
+
const noFollow = 'O_NOFOLLOW' in constants ? constants.O_NOFOLLOW : 0;
|
|
1207
|
+
const oDirectory = 'O_DIRECTORY' in constants ? constants.O_DIRECTORY : 0;
|
|
1208
|
+
let rootHandle;
|
|
1209
|
+
try {
|
|
1210
|
+
rootHandle = await open(workloadDir, constants.O_RDONLY | noFollow | oDirectory);
|
|
1211
|
+
}
|
|
1212
|
+
catch (err) {
|
|
1213
|
+
const code = err?.code;
|
|
1214
|
+
if (code === 'ENOENT') {
|
|
1215
|
+
throw new HardwareRunnerError('CONFIG_INVALID', `worker held-out workload "${heldOutWorkloadId}" does not exist`, '/heldOutWorkloadsDir');
|
|
1216
|
+
}
|
|
1217
|
+
if (code === 'ELOOP' || code === 'ENOTDIR') {
|
|
1218
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', `held-out workload "${heldOutWorkloadId}" must be a non-symlink directory`);
|
|
1219
|
+
}
|
|
1220
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', `unable to open held-out workload "${heldOutWorkloadId}"`);
|
|
1221
|
+
}
|
|
1222
|
+
try {
|
|
1223
|
+
const rootStat = await rootHandle.stat();
|
|
1224
|
+
if (!rootStat.isDirectory() || rootStat.isSymbolicLink()) {
|
|
1225
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'held-out workload path is not a regular directory');
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
finally {
|
|
1229
|
+
await rootHandle.close();
|
|
1230
|
+
}
|
|
1231
|
+
let resolvedSnapRoot = null;
|
|
1232
|
+
const createdSnapDirs = [];
|
|
1233
|
+
if (snapshotDestDir !== null) {
|
|
1234
|
+
resolvedSnapRoot = resolve(snapshotDestDir);
|
|
1235
|
+
await assertNoSymlinkAncestors(resolvedSnapRoot, {
|
|
1236
|
+
checkLeaf: true,
|
|
1237
|
+
code: 'RUNNER_SANDBOX_FAILED',
|
|
1238
|
+
diagPath: '/workloadSnapshotDir',
|
|
1239
|
+
});
|
|
1240
|
+
await mkdir(resolvedSnapRoot, { mode: 0o700 });
|
|
1241
|
+
const snapStat = await lstat(resolvedSnapRoot);
|
|
1242
|
+
if (snapStat.isSymbolicLink() || !snapStat.isDirectory()) {
|
|
1243
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'workloadSnapshotDir must be a non-symlink directory');
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
const realWorkloadDir = await realpath(workloadDir);
|
|
1247
|
+
const maxFiles = options.maxFiles ?? 4_096;
|
|
1248
|
+
const maxFileBytes = options.maxFileBytes ?? VERIFIER_ARTIFACT_LIMITS.maxFileBytes;
|
|
1249
|
+
const maxTotalBytes = options.maxTotalBytes ?? VERIFIER_ARTIFACT_LIMITS.maxTotalBytes;
|
|
1250
|
+
const maxDepth = options.maxDepth ?? 32;
|
|
1251
|
+
const entries = [];
|
|
1252
|
+
let totalBytes = 0;
|
|
1253
|
+
const isInsideRealWorkload = (candidateReal) => candidateReal === realWorkloadDir
|
|
1254
|
+
|| candidateReal.startsWith(realWorkloadDir.endsWith(sep) ? realWorkloadDir : `${realWorkloadDir}${sep}`);
|
|
1255
|
+
const walk = async (currentAbs, relPrefix, currentSnapDir, depth) => {
|
|
1256
|
+
if (depth > maxDepth) {
|
|
1257
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'held-out workload exceeds maximum directory nesting depth');
|
|
1258
|
+
}
|
|
1259
|
+
if (options.signal?.aborted) {
|
|
1260
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'workload digest walk aborted');
|
|
1261
|
+
}
|
|
1262
|
+
const dirHandle = await open(currentAbs, constants.O_RDONLY | noFollow | oDirectory).catch(() => {
|
|
1263
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', 'symlink or unreadable directory inside held_out_workloads');
|
|
1264
|
+
});
|
|
1265
|
+
await dirHandle.close();
|
|
1266
|
+
const dirents = await readdir(currentAbs, { withFileTypes: true });
|
|
1267
|
+
dirents.sort((a, b) => compareUtf16(a.name, b.name));
|
|
1268
|
+
for (const dirent of dirents) {
|
|
1269
|
+
if (dirent.isSymbolicLink()) {
|
|
1270
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', `symlink "${dirent.name}" is forbidden inside held_out_workloads`);
|
|
1271
|
+
}
|
|
1272
|
+
const childAbs = join(currentAbs, dirent.name);
|
|
1273
|
+
const childRel = relPrefix.length === 0 ? dirent.name : `${relPrefix}/${dirent.name}`;
|
|
1274
|
+
const st = await lstat(childAbs).catch(() => null);
|
|
1275
|
+
if (st === null || st.isSymbolicLink()) {
|
|
1276
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', `symlink or vanished entry "${childRel}" inside held_out_workloads`);
|
|
1277
|
+
}
|
|
1278
|
+
const realChild = await realpath(childAbs).catch(() => {
|
|
1279
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', `unable to resolve "${childRel}" inside held_out_workloads`);
|
|
1280
|
+
});
|
|
1281
|
+
if (!isInsideRealWorkload(realChild)) {
|
|
1282
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', `entry "${childRel}" escapes held-out workload directory`);
|
|
1283
|
+
}
|
|
1284
|
+
const childSnapPath = currentSnapDir !== null ? join(currentSnapDir, dirent.name) : null;
|
|
1285
|
+
if (st.isDirectory()) {
|
|
1286
|
+
if (childSnapPath !== null) {
|
|
1287
|
+
await mkdir(childSnapPath, { mode: 0o700 });
|
|
1288
|
+
const createdSt = await lstat(childSnapPath);
|
|
1289
|
+
if (createdSt.isSymbolicLink() || !createdSt.isDirectory()) {
|
|
1290
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'symlink detected while creating workload snapshot directory');
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
await walk(childAbs, childRel, childSnapPath, depth + 1);
|
|
1294
|
+
if (childSnapPath !== null) {
|
|
1295
|
+
createdSnapDirs.push(childSnapPath);
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
else if (st.isFile()) {
|
|
1299
|
+
if (entries.length >= maxFiles) {
|
|
1300
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', `held-out workload exceeds ${maxFiles} files`);
|
|
1301
|
+
}
|
|
1302
|
+
const hashed = await streamWorkloadFileNoFollow(childAbs, maxFileBytes, childSnapPath, options.signal);
|
|
1303
|
+
if (hashed.bytes > maxTotalBytes - totalBytes) {
|
|
1304
|
+
throw new HardwareRunnerError('PAYLOAD_TOO_LARGE', `held-out workload exceeds ${maxTotalBytes} total bytes`);
|
|
1305
|
+
}
|
|
1306
|
+
totalBytes += hashed.bytes;
|
|
1307
|
+
entries.push({ relPath: childRel, bytes: hashed.bytes, sha256: hashed.sha256 });
|
|
1308
|
+
}
|
|
1309
|
+
else {
|
|
1310
|
+
throw new HardwareRunnerError('ARTIFACT_INVALID', `unsupported special file "${childRel}" in held_out_workloads`);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1314
|
+
await walk(workloadDir, '', resolvedSnapRoot, 0);
|
|
1315
|
+
if (resolvedSnapRoot !== null) {
|
|
1316
|
+
for (const snapSubDir of createdSnapDirs) {
|
|
1317
|
+
await chmod(snapSubDir, 0o500);
|
|
1318
|
+
}
|
|
1319
|
+
await chmod(resolvedSnapRoot, 0o500);
|
|
1320
|
+
}
|
|
1321
|
+
entries.sort((a, b) => compareUtf16(a.relPath, b.relPath));
|
|
1322
|
+
const treeHasher = createHash('sha256');
|
|
1323
|
+
treeHasher.update(`${WORKLOAD_TREE_DOMAIN}\n`, 'utf8');
|
|
1324
|
+
for (const item of entries) {
|
|
1325
|
+
treeHasher.update(`${item.relPath}\0${item.bytes}\0${item.sha256}\n`, 'utf8');
|
|
1326
|
+
}
|
|
1327
|
+
return Object.freeze({
|
|
1328
|
+
workloadDir: resolvedSnapRoot ?? workloadDir,
|
|
1329
|
+
digest: Object.freeze({ algorithm: 'sha256', hex: treeHasher.digest('hex') }),
|
|
1330
|
+
fileCount: entries.length,
|
|
1331
|
+
totalBytes,
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Deterministically compute the SHA-256 tree digest over `<heldOutWorkloadsDir>/<heldOutWorkloadId>`
|
|
1336
|
+
* verifying `O_NOFOLLOW` across every ancestor, subdirectory, and file while rejecting symlinks and hardlinks.
|
|
1337
|
+
*/
|
|
1338
|
+
export async function computeHeldOutWorkloadDigest(heldOutWorkloadsDir, heldOutWorkloadId, options = {}) {
|
|
1339
|
+
return processHeldOutWorkloadTree(heldOutWorkloadsDir, heldOutWorkloadId, null, options);
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Atomically copy `<heldOutWorkloadsDir>/<heldOutWorkloadId>` into an immutable private `0o500`/`0o400`
|
|
1343
|
+
* snapshot directory while computing its deterministic SHA-256 tree digest over the exact copied bytes,
|
|
1344
|
+
* eliminating any TOCTOU window between Stage A compilation and Stage B blind execution.
|
|
1345
|
+
*/
|
|
1346
|
+
export async function snapshotHeldOutWorkload(heldOutWorkloadsDir, heldOutWorkloadId, snapshotDestDir, options = {}) {
|
|
1347
|
+
const res = await processHeldOutWorkloadTree(heldOutWorkloadsDir, heldOutWorkloadId, snapshotDestDir, options);
|
|
1348
|
+
return Object.freeze({
|
|
1349
|
+
snapshotDir: res.workloadDir,
|
|
1350
|
+
digest: res.digest,
|
|
1351
|
+
fileCount: res.fileCount,
|
|
1352
|
+
totalBytes: res.totalBytes,
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
function inferAcceleratorFamily(accelerator) {
|
|
1356
|
+
const lower = accelerator.toLowerCase();
|
|
1357
|
+
if (lower.startsWith('sm_'))
|
|
1358
|
+
return 'nvidia';
|
|
1359
|
+
if (lower.startsWith('gfx'))
|
|
1360
|
+
return 'amd';
|
|
1361
|
+
if (lower.startsWith('ascend'))
|
|
1362
|
+
return 'huawei';
|
|
1363
|
+
return 'unknown';
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Collect authenticated `HardwareProvenance` either from deterministic `synthetic_fixture` metadata
|
|
1367
|
+
* (never spoofing `'physical'`) or by executing trusted host accelerator binaries (`nvidia-smi`,
|
|
1368
|
+
* `rocm-smi`/`rocminfo`, `npu-smi`) with `shell: false`. Never injects unobserved topology or
|
|
1369
|
+
* derived runtime versions on physical probes.
|
|
1370
|
+
*/
|
|
1371
|
+
export async function collectHardwareProvenance(options) {
|
|
1372
|
+
const { capabilities, targetCellId, targetHardware, workloadDigest } = options;
|
|
1373
|
+
if (options.probeMode === 'synthetic_fixture') {
|
|
1374
|
+
const family = inferAcceleratorFamily(capabilities.accelerator);
|
|
1375
|
+
const vendor = family === 'unknown' ? 'synthetic' : family;
|
|
1376
|
+
const isolationMode = targetHardware !== undefined && capabilities.isolationModes.includes(targetHardware.isolationMode)
|
|
1377
|
+
? targetHardware.isolationMode
|
|
1378
|
+
: capabilities.isolationModes[0];
|
|
1379
|
+
const requestedSynthetic = targetHardware?.deviceCount ?? 1;
|
|
1380
|
+
const allocatedDevices = Math.min(capabilities.deviceCount, Math.max(1, requestedSynthetic));
|
|
1381
|
+
const topology = capabilities.topology;
|
|
1382
|
+
const out = Object.create(null);
|
|
1383
|
+
out.targetCellId = targetCellId;
|
|
1384
|
+
out.probeKind = 'synthetic_fixture';
|
|
1385
|
+
out.vendor = vendor;
|
|
1386
|
+
out.deviceModel = `Loopwright Synthetic Fixture (${capabilities.accelerator})`;
|
|
1387
|
+
out.accelerator = capabilities.accelerator;
|
|
1388
|
+
out.isolationMode = isolationMode;
|
|
1389
|
+
out.deviceCount = allocatedDevices;
|
|
1390
|
+
out.driverVersion = capabilities.driverVersion;
|
|
1391
|
+
out.runtimeVersion = `${vendor}-synthetic-1.0`;
|
|
1392
|
+
if (topology !== undefined)
|
|
1393
|
+
out.topology = topology;
|
|
1394
|
+
out.workloadDigest = Object.freeze({ algorithm: 'sha256', hex: workloadDigest.hex });
|
|
1395
|
+
out.clockLockMode = 'unknown';
|
|
1396
|
+
return Object.freeze(out);
|
|
1397
|
+
}
|
|
1398
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
|
|
1399
|
+
const runner = options.commandRunner ?? defaultProbeCommandRunner;
|
|
1400
|
+
const verifier = options.verifyExecutable ?? ((binPath, allowlist) => verifyTrustedProbeExecutable(binPath, allowlist));
|
|
1401
|
+
const preferredAccelerator = targetHardware?.accelerator ?? capabilities.accelerator;
|
|
1402
|
+
// Default omitted deviceCount to 1 (matching Docker's single-device grant) so physical provenance
|
|
1403
|
+
// never overstates allocation or reports links across unallocated host devices.
|
|
1404
|
+
const effectiveAllocatedCount = targetHardware?.deviceCount ?? (options.allocatedDeviceIndices?.length ?? 1);
|
|
1405
|
+
if (!Number.isSafeInteger(effectiveAllocatedCount) || effectiveAllocatedCount < 1 || effectiveAllocatedCount > 64) {
|
|
1406
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `invalid targetHardware.deviceCount (${String(effectiveAllocatedCount)})`);
|
|
1407
|
+
}
|
|
1408
|
+
const explicitAllocatedIndices = options.allocatedDeviceIndices;
|
|
1409
|
+
const family = inferAcceleratorFamily(capabilities.accelerator);
|
|
1410
|
+
const runOpts = { timeoutMs, ...(options.signal !== undefined ? { signal: options.signal } : {}) };
|
|
1411
|
+
const ignoreHostRuntimeVersion = options.sandboxBackend === 'docker' && options.measuredRuntimeVersion === undefined;
|
|
1412
|
+
let probed;
|
|
1413
|
+
if (family === 'nvidia') {
|
|
1414
|
+
const nvidiaBin = await resolveFirstTrustedProbeExecutable(options.executableOverrides?.nvidiaSmiPath, TRUSTED_NVIDIA_SMI_PATHS, verifier);
|
|
1415
|
+
const queryRes = await runner(nvidiaBin, ['--query-gpu=name,compute_cap,driver_version,mig.mode.current', '--format=csv,noheader,nounits'], runOpts);
|
|
1416
|
+
if (queryRes.exitCode !== 0) {
|
|
1417
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'nvidia-smi query command exited with non-zero status');
|
|
1418
|
+
}
|
|
1419
|
+
const targetDetailIds = explicitAllocatedIndices !== undefined
|
|
1420
|
+
? explicitAllocatedIndices.join(',')
|
|
1421
|
+
: Array.from({ length: effectiveAllocatedCount }, (_, idx) => String(idx)).join(',');
|
|
1422
|
+
const detailRes = await runner(nvidiaBin, ['-i', targetDetailIds, '-q'], runOpts).catch(() => ({
|
|
1423
|
+
exitCode: 1,
|
|
1424
|
+
stdout: '',
|
|
1425
|
+
stderr: '',
|
|
1426
|
+
}));
|
|
1427
|
+
const topoRes = await runner(nvidiaBin, ['topo', '-m'], runOpts).catch(() => ({ exitCode: 1, stdout: '', stderr: '' }));
|
|
1428
|
+
probed = parseNvidiaSmiOutput(queryRes.stdout, detailRes.exitCode === 0 ? detailRes.stdout : '', {
|
|
1429
|
+
preferredAccelerator,
|
|
1430
|
+
topoOutput: topoRes.exitCode === 0 ? topoRes.stdout : '',
|
|
1431
|
+
allocatedDeviceCount: effectiveAllocatedCount,
|
|
1432
|
+
...(explicitAllocatedIndices !== undefined ? { allocatedDeviceIndices: explicitAllocatedIndices } : {}),
|
|
1433
|
+
detailScopedToAllocated: true,
|
|
1434
|
+
...(options.measuredRuntimeVersion !== undefined ? { measuredRuntimeVersion: options.measuredRuntimeVersion } : {}),
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
else if (family === 'amd') {
|
|
1438
|
+
const rocmSmiBin = await resolveFirstTrustedProbeExecutable(options.executableOverrides?.rocmSmiPath, TRUSTED_ROCM_SMI_PATHS, verifier);
|
|
1439
|
+
let smiRes = await runner(rocmSmiBin, ['--showproductname', '--showdriverversion', '--json'], runOpts);
|
|
1440
|
+
if (smiRes.exitCode !== 0 || smiRes.stdout.trim().length === 0) {
|
|
1441
|
+
smiRes = await runner(rocmSmiBin, ['--showproductname', '--showdriverversion'], runOpts);
|
|
1442
|
+
}
|
|
1443
|
+
const topoRes = await runner(rocmSmiBin, ['--showtopo'], runOpts).catch(() => ({ exitCode: 1, stdout: '', stderr: '' }));
|
|
1444
|
+
let rocminfoOut = '';
|
|
1445
|
+
try {
|
|
1446
|
+
const rocminfoBin = await resolveFirstTrustedProbeExecutable(options.executableOverrides?.rocminfoPath, TRUSTED_ROCMINFO_PATHS, verifier);
|
|
1447
|
+
const infoRes = await runner(rocminfoBin, [], runOpts);
|
|
1448
|
+
if (infoRes.exitCode === 0) {
|
|
1449
|
+
rocminfoOut = infoRes.stdout;
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
catch {
|
|
1453
|
+
// Optional enrichment when rocm-smi already reports GFX Version.
|
|
1454
|
+
}
|
|
1455
|
+
if (smiRes.exitCode !== 0 && rocminfoOut.trim().length === 0) {
|
|
1456
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'rocm-smi and rocminfo probes exited with non-zero status');
|
|
1457
|
+
}
|
|
1458
|
+
probed = parseRocmSmiOutput(smiRes.exitCode === 0 ? smiRes.stdout : '', rocminfoOut, {
|
|
1459
|
+
topoOutput: topoRes.exitCode === 0 ? topoRes.stdout : '',
|
|
1460
|
+
allocatedDeviceCount: effectiveAllocatedCount,
|
|
1461
|
+
...(explicitAllocatedIndices !== undefined ? { allocatedDeviceIndices: explicitAllocatedIndices } : {}),
|
|
1462
|
+
ignoreHostRuntimeVersion,
|
|
1463
|
+
...(options.measuredRuntimeVersion !== undefined ? { measuredRuntimeVersion: options.measuredRuntimeVersion } : {}),
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
else if (family === 'huawei') {
|
|
1467
|
+
const npuBin = await resolveFirstTrustedProbeExecutable(options.executableOverrides?.npuSmiPath, TRUSTED_NPU_SMI_PATHS, verifier);
|
|
1468
|
+
const npuRes = await runner(npuBin, ['info'], runOpts);
|
|
1469
|
+
if (npuRes.exitCode !== 0) {
|
|
1470
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', 'npu-smi info command exited with non-zero status');
|
|
1471
|
+
}
|
|
1472
|
+
const topoRes = await runner(npuBin, ['info', '-t', 'topo'], runOpts).catch(() => ({ exitCode: 1, stdout: '', stderr: '' }));
|
|
1473
|
+
probed = parseNpuSmiOutput(npuRes.stdout, {
|
|
1474
|
+
preferredAccelerator,
|
|
1475
|
+
topoOutput: topoRes.exitCode === 0 ? topoRes.stdout : '',
|
|
1476
|
+
allocatedDeviceCount: effectiveAllocatedCount,
|
|
1477
|
+
...(explicitAllocatedIndices !== undefined ? { allocatedDeviceIndices: explicitAllocatedIndices } : {}),
|
|
1478
|
+
ignoreHostRuntimeVersion,
|
|
1479
|
+
...(options.measuredRuntimeVersion !== undefined ? { measuredRuntimeVersion: options.measuredRuntimeVersion } : {}),
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1482
|
+
else {
|
|
1483
|
+
throw new HardwareRunnerError('RUNNER_SANDBOX_FAILED', `unsupported physical accelerator family for "${capabilities.accelerator}"`);
|
|
1484
|
+
}
|
|
1485
|
+
const out = Object.create(null);
|
|
1486
|
+
out.targetCellId = targetCellId;
|
|
1487
|
+
out.probeKind = 'physical';
|
|
1488
|
+
out.vendor = probed.vendor;
|
|
1489
|
+
out.deviceModel = probed.deviceModel;
|
|
1490
|
+
out.accelerator = probed.accelerator;
|
|
1491
|
+
out.isolationMode = probed.isolationMode;
|
|
1492
|
+
out.deviceCount = probed.deviceCount;
|
|
1493
|
+
out.driverVersion = probed.driverVersion;
|
|
1494
|
+
out.runtimeVersion = probed.runtimeVersion;
|
|
1495
|
+
if (probed.topology !== undefined)
|
|
1496
|
+
out.topology = probed.topology;
|
|
1497
|
+
out.workloadDigest = Object.freeze({ algorithm: 'sha256', hex: workloadDigest.hex });
|
|
1498
|
+
out.clockLockMode = probed.clockLockMode;
|
|
1499
|
+
return Object.freeze(out);
|
|
1500
|
+
}
|