@gpustack/loopwright 0.0.0-stage → 0.0.2
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 +2083 -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 +1646 -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 +2605 -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 +7313 -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 +3021 -0
- package/package-lock.json +3021 -0
- package/package.json +52 -4
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { lstat, mkdir, open, readdir, realpath, rename, unlink } from 'node:fs/promises';
|
|
4
|
+
import { dirname, join, posix, resolve, sep } from 'node:path';
|
|
5
|
+
import { TaskpackError, } from './types.js';
|
|
6
|
+
import { IDENTIFIER_PATTERN, normalizeRelativePath, parseJsonSubset, resolveTaskpackResourcePath, tryNormalizeRelativePath, } from './schema.js';
|
|
7
|
+
export const DIGEST_STREAM_CHUNK_BYTES = 1_048_576;
|
|
8
|
+
export const DIGEST_MAX_FILE_BYTES = 16 * 1024 * 1024;
|
|
9
|
+
export const DIGEST_MAX_TREE_FILES = 1_024;
|
|
10
|
+
export const DIGEST_MAX_TREE_BYTES = 64 * 1024 * 1024;
|
|
11
|
+
export const DIGEST_MAX_TREE_DEPTH = 32;
|
|
12
|
+
export const DIGEST_LOCKFILE_MAX_BYTES = 262_144;
|
|
13
|
+
export const DIGEST_LOCKFILE_MAX_ENTRIES = 512;
|
|
14
|
+
const SHA256_HEX_PATTERN = /^[0-9a-f]{64}$/;
|
|
15
|
+
const FORBIDDEN_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
16
|
+
function compareCodePoint(a, b) {
|
|
17
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
18
|
+
}
|
|
19
|
+
function isContainedInRoot(candidate, realRoot) {
|
|
20
|
+
if (candidate === realRoot)
|
|
21
|
+
return true;
|
|
22
|
+
const prefix = realRoot.endsWith(sep) ? realRoot : `${realRoot}${sep}`;
|
|
23
|
+
return candidate.startsWith(prefix);
|
|
24
|
+
}
|
|
25
|
+
async function resolveSafeRepoRoot(repoRoot) {
|
|
26
|
+
const resolvedRoot = resolve(repoRoot);
|
|
27
|
+
const rootStat = await lstat(resolvedRoot).catch(() => null);
|
|
28
|
+
if (rootStat === null || rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
|
|
29
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'repository root must be an existing non-symlink directory', '/');
|
|
30
|
+
}
|
|
31
|
+
const realRoot = await realpath(resolvedRoot).catch(() => {
|
|
32
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'repository root cannot be resolved', '/');
|
|
33
|
+
});
|
|
34
|
+
return { resolvedRoot, realRoot };
|
|
35
|
+
}
|
|
36
|
+
async function resolveExistingSafeSubpath(repoRoot, relPath, diagPath) {
|
|
37
|
+
const normalized = normalizeRelativePath(relPath, diagPath);
|
|
38
|
+
const { resolvedRoot, realRoot } = await resolveSafeRepoRoot(repoRoot);
|
|
39
|
+
const segments = normalized.split('/');
|
|
40
|
+
let current = resolvedRoot;
|
|
41
|
+
for (const segment of segments) {
|
|
42
|
+
current = join(current, segment);
|
|
43
|
+
const st = await lstat(current).catch(() => null);
|
|
44
|
+
if (st === null) {
|
|
45
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `path "${normalized}" does not exist`, diagPath);
|
|
46
|
+
}
|
|
47
|
+
if (st.isSymbolicLink()) {
|
|
48
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `path "${normalized}" must not traverse or target symbolic links`, diagPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const realFullPath = await realpath(current).catch(() => {
|
|
52
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `path "${normalized}" cannot be resolved`, diagPath);
|
|
53
|
+
});
|
|
54
|
+
if (!isContainedInRoot(realFullPath, realRoot)) {
|
|
55
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `path "${normalized}" escapes repository root`, diagPath);
|
|
56
|
+
}
|
|
57
|
+
return { fullPath: current, realRoot, realFullPath };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Stream a regular non-symlink, non-hardlinked (`nlink === 1`) file in `64 KiB` chunks
|
|
61
|
+
* through `O_RDONLY | O_NOFOLLOW` into SHA-256 with pre/post `fstat` stability checks.
|
|
62
|
+
*/
|
|
63
|
+
async function hashStreamedRegularFile(fullPath, maxFileBytes, diagPath) {
|
|
64
|
+
let before;
|
|
65
|
+
try {
|
|
66
|
+
before = await lstat(fullPath);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const code = error?.code;
|
|
70
|
+
if (code === 'ELOOP') {
|
|
71
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: symbolic link traversal is forbidden`, diagPath);
|
|
72
|
+
}
|
|
73
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file does not exist or cannot be inspected`, diagPath);
|
|
74
|
+
}
|
|
75
|
+
if (before.isSymbolicLink()) {
|
|
76
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: file must not be a symbolic link`, diagPath);
|
|
77
|
+
}
|
|
78
|
+
if (!before.isFile()) {
|
|
79
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: path must be a regular file`, diagPath);
|
|
80
|
+
}
|
|
81
|
+
if (before.nlink !== 1) {
|
|
82
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: hardlinked file (nlink=${before.nlink}) is forbidden`, diagPath);
|
|
83
|
+
}
|
|
84
|
+
if (before.size > maxFileBytes) {
|
|
85
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file exceeds ${maxFileBytes} bytes`, diagPath);
|
|
86
|
+
}
|
|
87
|
+
const noFollow = 'O_NOFOLLOW' in constants ? constants.O_NOFOLLOW : 0;
|
|
88
|
+
let handle;
|
|
89
|
+
try {
|
|
90
|
+
handle = await open(fullPath, constants.O_RDONLY | noFollow);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const code = error?.code;
|
|
94
|
+
if (code === 'ELOOP') {
|
|
95
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: symbolic link detected while opening file`, diagPath);
|
|
96
|
+
}
|
|
97
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file could not be opened`, diagPath);
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const info = await handle.stat();
|
|
101
|
+
if (!info.isFile() || info.nlink !== 1 || info.dev !== before.dev || info.ino !== before.ino) {
|
|
102
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: file identity or link count changed while opening`, diagPath);
|
|
103
|
+
}
|
|
104
|
+
if (info.size !== before.size || info.size > maxFileBytes) {
|
|
105
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file changed size while loading or exceeds ${maxFileBytes} bytes`, diagPath);
|
|
106
|
+
}
|
|
107
|
+
const hash = createHash('sha256');
|
|
108
|
+
const chunk = Buffer.allocUnsafe(Math.min(DIGEST_STREAM_CHUNK_BYTES, Math.max(1, info.size)));
|
|
109
|
+
let offset = 0;
|
|
110
|
+
while (offset < info.size) {
|
|
111
|
+
const toRead = Math.min(chunk.byteLength, info.size - offset);
|
|
112
|
+
const { bytesRead } = await handle.read(chunk, 0, toRead, offset);
|
|
113
|
+
if (bytesRead <= 0)
|
|
114
|
+
break;
|
|
115
|
+
hash.update(chunk.subarray(0, bytesRead));
|
|
116
|
+
offset += bytesRead;
|
|
117
|
+
}
|
|
118
|
+
// Probe one byte past expected EOF to catch concurrent file growth.
|
|
119
|
+
const extra = await handle.read(chunk, 0, 1, offset);
|
|
120
|
+
const after = await handle.stat();
|
|
121
|
+
if (extra.bytesRead !== 0
|
|
122
|
+
|| offset !== info.size
|
|
123
|
+
|| after.size !== info.size
|
|
124
|
+
|| after.nlink !== 1
|
|
125
|
+
|| after.dev !== info.dev
|
|
126
|
+
|| after.ino !== info.ino
|
|
127
|
+
|| after.mtimeMs !== info.mtimeMs
|
|
128
|
+
|| after.ctimeMs !== info.ctimeMs) {
|
|
129
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file mutated while hashing`, diagPath);
|
|
130
|
+
}
|
|
131
|
+
return { sha256: hash.digest('hex'), bytes: offset };
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
await handle.close();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Bounded control-file reader used exclusively for small `digests.lock.json` documents. */
|
|
138
|
+
async function readBoundedControlFile(fullPath, maxBytes, diagPath) {
|
|
139
|
+
let before;
|
|
140
|
+
try {
|
|
141
|
+
before = await lstat(fullPath);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
const code = error?.code;
|
|
145
|
+
if (code === 'ELOOP') {
|
|
146
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: symbolic link traversal is forbidden`, diagPath);
|
|
147
|
+
}
|
|
148
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file does not exist or cannot be inspected`, diagPath);
|
|
149
|
+
}
|
|
150
|
+
if (before.isSymbolicLink()) {
|
|
151
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: file must not be a symbolic link`, diagPath);
|
|
152
|
+
}
|
|
153
|
+
if (!before.isFile()) {
|
|
154
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: path must be a regular file`, diagPath);
|
|
155
|
+
}
|
|
156
|
+
if (before.nlink !== 1) {
|
|
157
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: hardlinked file (nlink=${before.nlink}) is forbidden`, diagPath);
|
|
158
|
+
}
|
|
159
|
+
if (before.size > maxBytes) {
|
|
160
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file exceeds ${maxBytes} bytes`, diagPath);
|
|
161
|
+
}
|
|
162
|
+
const noFollow = 'O_NOFOLLOW' in constants ? constants.O_NOFOLLOW : 0;
|
|
163
|
+
let handle;
|
|
164
|
+
try {
|
|
165
|
+
handle = await open(fullPath, constants.O_RDONLY | noFollow);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
const code = error?.code;
|
|
169
|
+
if (code === 'ELOOP') {
|
|
170
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: symbolic link detected while opening file`, diagPath);
|
|
171
|
+
}
|
|
172
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file could not be opened`, diagPath);
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
const info = await handle.stat();
|
|
176
|
+
if (!info.isFile() || info.nlink !== 1 || info.dev !== before.dev || info.ino !== before.ino) {
|
|
177
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `${diagPath}: file identity or link count changed while opening`, diagPath);
|
|
178
|
+
}
|
|
179
|
+
if (info.size !== before.size || info.size > maxBytes) {
|
|
180
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file changed size while loading or exceeds ${maxBytes} bytes`, diagPath);
|
|
181
|
+
}
|
|
182
|
+
const buf = Buffer.alloc(info.size + 1);
|
|
183
|
+
let size = 0;
|
|
184
|
+
while (size < buf.length) {
|
|
185
|
+
const read = await handle.read(buf, size, buf.length - size, size);
|
|
186
|
+
if (!read.bytesRead)
|
|
187
|
+
break;
|
|
188
|
+
size += read.bytesRead;
|
|
189
|
+
}
|
|
190
|
+
if (size !== info.size) {
|
|
191
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `${diagPath}: file changed while loading`, diagPath);
|
|
192
|
+
}
|
|
193
|
+
return buf.subarray(0, size);
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
await handle.close();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Compute the lowercase SHA-256 hex digest of a single regular file inside `repoRoot`
|
|
201
|
+
* by streaming `64 KiB` chunks with `O_NOFOLLOW` and `nlink === 1`.
|
|
202
|
+
*/
|
|
203
|
+
export async function computeFileDigest(repoRoot, relPath, options = {}) {
|
|
204
|
+
const normalized = normalizeRelativePath(relPath, relPath);
|
|
205
|
+
const maxFileBytes = options.maxFileBytes ?? DIGEST_MAX_FILE_BYTES;
|
|
206
|
+
const { fullPath } = await resolveExistingSafeSubpath(repoRoot, normalized, normalized);
|
|
207
|
+
const { sha256 } = await hashStreamedRegularFile(fullPath, maxFileBytes, normalized);
|
|
208
|
+
return sha256;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Deterministically walk a directory inside `repoRoot` and compute a whole-tree SHA-256 digest
|
|
212
|
+
* covering every nested regular file's relative POSIX path, byte length, and content SHA-256.
|
|
213
|
+
* Rejects any symlink, hardlink (`nlink !== 1`), escape outside `repoRoot`, special file, or bound violation.
|
|
214
|
+
*/
|
|
215
|
+
export async function computeDirectoryTreeDigest(repoRoot, relDir, options = {}) {
|
|
216
|
+
const normalized = normalizeRelativePath(relDir, relDir);
|
|
217
|
+
const maxFileBytes = options.maxFileBytes ?? DIGEST_MAX_FILE_BYTES;
|
|
218
|
+
const maxTreeFiles = options.maxTreeFiles ?? DIGEST_MAX_TREE_FILES;
|
|
219
|
+
const maxTreeBytes = options.maxTreeBytes ?? DIGEST_MAX_TREE_BYTES;
|
|
220
|
+
const maxTreeDepth = options.maxTreeDepth ?? DIGEST_MAX_TREE_DEPTH;
|
|
221
|
+
const { fullPath, realRoot } = await resolveExistingSafeSubpath(repoRoot, normalized, normalized);
|
|
222
|
+
const dirStat = await lstat(fullPath).catch(() => null);
|
|
223
|
+
if (dirStat === null || dirStat.isSymbolicLink() || !dirStat.isDirectory()) {
|
|
224
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `directory "${normalized}" must be a non-symlink directory`, normalized);
|
|
225
|
+
}
|
|
226
|
+
const files = [];
|
|
227
|
+
let totalBytes = 0;
|
|
228
|
+
const walk = async (absDir, relPrefix, depth) => {
|
|
229
|
+
if (depth > maxTreeDepth) {
|
|
230
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `directory "${normalized}" exceeds maximum nesting depth ${maxTreeDepth}`, normalized);
|
|
231
|
+
}
|
|
232
|
+
const entries = await readdir(absDir, { withFileTypes: true });
|
|
233
|
+
entries.sort((a, b) => compareCodePoint(a.name, b.name));
|
|
234
|
+
for (const entry of entries) {
|
|
235
|
+
const childAbs = join(absDir, entry.name);
|
|
236
|
+
const childRel = relPrefix.length === 0 ? entry.name : `${relPrefix}/${entry.name}`;
|
|
237
|
+
const diagPath = `${normalized}/${childRel}`;
|
|
238
|
+
if (entry.isSymbolicLink()) {
|
|
239
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `symlink "${diagPath}" is forbidden inside hashed directory "${normalized}"`, diagPath);
|
|
240
|
+
}
|
|
241
|
+
const st = await lstat(childAbs).catch(() => null);
|
|
242
|
+
if (st === null) {
|
|
243
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `entry "${diagPath}" disappeared while hashing`, diagPath);
|
|
244
|
+
}
|
|
245
|
+
if (st.isSymbolicLink()) {
|
|
246
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `symlink "${diagPath}" is forbidden inside hashed directory "${normalized}"`, diagPath);
|
|
247
|
+
}
|
|
248
|
+
if (st.isDirectory()) {
|
|
249
|
+
const realChild = await realpath(childAbs).catch(() => {
|
|
250
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `directory "${diagPath}" cannot be resolved`, diagPath);
|
|
251
|
+
});
|
|
252
|
+
if (!isContainedInRoot(realChild, realRoot)) {
|
|
253
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `directory "${diagPath}" escapes repository root`, diagPath);
|
|
254
|
+
}
|
|
255
|
+
await walk(childAbs, childRel, depth + 1);
|
|
256
|
+
}
|
|
257
|
+
else if (st.isFile()) {
|
|
258
|
+
if (st.nlink !== 1) {
|
|
259
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `hardlinked file "${diagPath}" (nlink=${st.nlink}) is forbidden inside hashed directory "${normalized}"`, diagPath);
|
|
260
|
+
}
|
|
261
|
+
if (files.length >= maxTreeFiles) {
|
|
262
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `directory "${normalized}" exceeds ${maxTreeFiles} files`, diagPath);
|
|
263
|
+
}
|
|
264
|
+
if (st.size > maxFileBytes || totalBytes + st.size > maxTreeBytes) {
|
|
265
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `directory "${normalized}" exceeds byte limit ${maxTreeBytes}`, diagPath);
|
|
266
|
+
}
|
|
267
|
+
const realChild = await realpath(childAbs).catch(() => {
|
|
268
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `file "${diagPath}" cannot be resolved`, diagPath);
|
|
269
|
+
});
|
|
270
|
+
if (!isContainedInRoot(realChild, realRoot)) {
|
|
271
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `file "${diagPath}" escapes repository root`, diagPath);
|
|
272
|
+
}
|
|
273
|
+
const hashed = await hashStreamedRegularFile(childAbs, maxFileBytes, diagPath);
|
|
274
|
+
totalBytes += hashed.bytes;
|
|
275
|
+
if (totalBytes > maxTreeBytes) {
|
|
276
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `directory "${normalized}" exceeds byte limit ${maxTreeBytes}`, diagPath);
|
|
277
|
+
}
|
|
278
|
+
files.push(Object.freeze({
|
|
279
|
+
path: childRel,
|
|
280
|
+
sha256: hashed.sha256,
|
|
281
|
+
bytes: hashed.bytes,
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `unsupported non-regular entry "${diagPath}" inside hashed directory`, diagPath);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
await walk(fullPath, '', 0);
|
|
290
|
+
files.sort((a, b) => compareCodePoint(a.path, b.path));
|
|
291
|
+
const treeHash = createHash('sha256');
|
|
292
|
+
treeHash.update('loopwright.dev/digests/tree/v1\n', 'utf8');
|
|
293
|
+
for (const file of files) {
|
|
294
|
+
treeHash.update(`${file.path}\0${file.bytes}\0${file.sha256}\n`, 'utf8');
|
|
295
|
+
}
|
|
296
|
+
return Object.freeze({
|
|
297
|
+
digest: treeHash.digest('hex'),
|
|
298
|
+
files: Object.freeze(files),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/** Resolve the repo-relative lockfile path for a taskpack manifest. */
|
|
302
|
+
export function resolveDigestLockfilePath(taskpack, controlRoot) {
|
|
303
|
+
const effectiveControlRoot = normalizeRelativePath(controlRoot ?? taskpack.controlRoot ?? '.loopwright', '/');
|
|
304
|
+
const declared = taskpack.spec.execution?.digests.lockfile;
|
|
305
|
+
if (declared !== undefined) {
|
|
306
|
+
return normalizeRelativePath(declared, '/spec/execution/digests/lockfile');
|
|
307
|
+
}
|
|
308
|
+
return `${effectiveControlRoot}/digests.lock.json`;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Collect all deterministic runtime-hashed files and check-script parent directories referenced
|
|
312
|
+
* by a Taskpack 2.0 manifest (`preflight.script`, `command.v1` parent directories, top-level and
|
|
313
|
+
* per-role `instructions` and `skills`).
|
|
314
|
+
*/
|
|
315
|
+
export function collectTaskpackDigestTargets(taskpack, controlRoot) {
|
|
316
|
+
if (controlRoot !== undefined) {
|
|
317
|
+
normalizeRelativePath(controlRoot, '/');
|
|
318
|
+
}
|
|
319
|
+
const seen = new Map();
|
|
320
|
+
const addTarget = (relPath, kind, diagPath) => {
|
|
321
|
+
const normalized = normalizeRelativePath(relPath, diagPath);
|
|
322
|
+
const key = `${kind}:${normalized}`;
|
|
323
|
+
if (!seen.has(key)) {
|
|
324
|
+
seen.set(key, Object.freeze({ path: normalized, kind }));
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
if (taskpack.spec.preflight !== undefined) {
|
|
328
|
+
addTarget(taskpack.spec.preflight.script, 'file', '/spec/preflight/script');
|
|
329
|
+
}
|
|
330
|
+
for (const [idx, check] of taskpack.spec.verification.localChecks.entries()) {
|
|
331
|
+
if (check.implementation !== 'command.v1')
|
|
332
|
+
continue;
|
|
333
|
+
const rawScript = check.parameters?.['script'];
|
|
334
|
+
if (typeof rawScript !== 'string' || rawScript.length === 0)
|
|
335
|
+
continue;
|
|
336
|
+
const scriptPath = normalizeRelativePath(rawScript, `/spec/verification/localChecks/${idx}/parameters/script`);
|
|
337
|
+
const parent = posix.dirname(scriptPath);
|
|
338
|
+
if (parent === '.' || parent === '') {
|
|
339
|
+
addTarget(scriptPath, 'file', `/spec/verification/localChecks/${idx}/parameters/script`);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
addTarget(parent, 'directory', `/spec/verification/localChecks/${idx}/parameters/script`);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
for (const [idx, instruction] of (taskpack.spec.instructions ?? []).entries()) {
|
|
346
|
+
addTarget(resolveTaskpackResourcePath(instruction), 'file', `/spec/instructions/${idx}`);
|
|
347
|
+
}
|
|
348
|
+
for (const [idx, skill] of (taskpack.spec.skills ?? []).entries()) {
|
|
349
|
+
addTarget(resolveTaskpackResourcePath(skill), 'file', `/spec/skills/${idx}`);
|
|
350
|
+
}
|
|
351
|
+
for (const [rIdx, role] of (taskpack.spec.roles ?? []).entries()) {
|
|
352
|
+
for (const [iIdx, instruction] of (role.instructions ?? []).entries()) {
|
|
353
|
+
addTarget(resolveTaskpackResourcePath(instruction), 'file', `/spec/roles/${rIdx}/instructions/${iIdx}`);
|
|
354
|
+
}
|
|
355
|
+
for (const [sIdx, skill] of (role.skills ?? []).entries()) {
|
|
356
|
+
addTarget(resolveTaskpackResourcePath(skill), 'file', `/spec/roles/${rIdx}/skills/${sIdx}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const targets = [...seen.values()];
|
|
360
|
+
targets.sort((a, b) => compareCodePoint(a.path, b.path) || compareCodePoint(a.kind, b.kind));
|
|
361
|
+
return Object.freeze(targets);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Compute a canonical deterministic `TaskpackDigestLockfile` for every tracked file and
|
|
365
|
+
* mounted check directory declared by `taskpack`.
|
|
366
|
+
*/
|
|
367
|
+
export async function computeTaskpackDigests(repoRoot, taskpack, controlRoot, options = {}) {
|
|
368
|
+
const maxFileBytes = options.maxFileBytes ?? DIGEST_MAX_FILE_BYTES;
|
|
369
|
+
for (const [idx, check] of taskpack.spec.verification.localChecks.entries()) {
|
|
370
|
+
if (check.implementation !== 'command.v1')
|
|
371
|
+
continue;
|
|
372
|
+
const rawScript = check.parameters?.['script'];
|
|
373
|
+
if (typeof rawScript !== 'string' || rawScript.length === 0)
|
|
374
|
+
continue;
|
|
375
|
+
const diagPath = `/spec/verification/localChecks/${idx}/parameters/script`;
|
|
376
|
+
const scriptPath = normalizeRelativePath(rawScript, diagPath);
|
|
377
|
+
const { fullPath } = await resolveExistingSafeSubpath(repoRoot, scriptPath, diagPath);
|
|
378
|
+
await hashStreamedRegularFile(fullPath, maxFileBytes, scriptPath);
|
|
379
|
+
}
|
|
380
|
+
const targets = collectTaskpackDigestTargets(taskpack, controlRoot);
|
|
381
|
+
const entries = [];
|
|
382
|
+
for (const target of targets) {
|
|
383
|
+
if (target.kind === 'directory') {
|
|
384
|
+
const tree = await computeDirectoryTreeDigest(repoRoot, target.path, options);
|
|
385
|
+
entries.push(Object.freeze({ path: target.path, kind: 'directory', sha256: tree.digest }));
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
const sha256 = await computeFileDigest(repoRoot, target.path, options);
|
|
389
|
+
entries.push(Object.freeze({ path: target.path, kind: 'file', sha256 }));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
entries.sort((a, b) => compareCodePoint(a.path, b.path) || compareCodePoint(a.kind, b.kind));
|
|
393
|
+
return Object.freeze({
|
|
394
|
+
version: 1,
|
|
395
|
+
taskpack: taskpack.metadata.name,
|
|
396
|
+
entries: Object.freeze(entries),
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
function validateLockfileObject(raw, diagPath) {
|
|
400
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
401
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'digest lockfile must be a JSON object', diagPath);
|
|
402
|
+
}
|
|
403
|
+
const proto = Object.getPrototypeOf(raw);
|
|
404
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
405
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'digest lockfile must be a plain object', diagPath);
|
|
406
|
+
}
|
|
407
|
+
const record = raw;
|
|
408
|
+
const allowedTop = new Set(['version', 'taskpack', 'entries']);
|
|
409
|
+
for (const key of Object.keys(record)) {
|
|
410
|
+
if (FORBIDDEN_KEYS.has(key) || !allowedTop.has(key)) {
|
|
411
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `unknown digest lockfile field "${key}"`, diagPath);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (record['version'] !== 1) {
|
|
415
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'digest lockfile version must be 1', `${diagPath}/version`);
|
|
416
|
+
}
|
|
417
|
+
const taskpackName = record['taskpack'];
|
|
418
|
+
if (typeof taskpackName !== 'string' || !IDENTIFIER_PATTERN.test(taskpackName)) {
|
|
419
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'digest lockfile taskpack must be a valid identifier', `${diagPath}/taskpack`);
|
|
420
|
+
}
|
|
421
|
+
const rawEntries = record['entries'];
|
|
422
|
+
if (!Array.isArray(rawEntries) || rawEntries.length > DIGEST_LOCKFILE_MAX_ENTRIES) {
|
|
423
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `digest lockfile entries must be an array of 0..${DIGEST_LOCKFILE_MAX_ENTRIES} items`, `${diagPath}/entries`);
|
|
424
|
+
}
|
|
425
|
+
const seen = new Set();
|
|
426
|
+
const entries = [];
|
|
427
|
+
const allowedEntryKeys = new Set(['path', 'kind', 'sha256']);
|
|
428
|
+
for (const [idx, item] of rawEntries.entries()) {
|
|
429
|
+
const itemPath = `${diagPath}/entries/${idx}`;
|
|
430
|
+
if (item === null || typeof item !== 'object' || Array.isArray(item)) {
|
|
431
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'digest lockfile entry must be an object', itemPath);
|
|
432
|
+
}
|
|
433
|
+
const itemProto = Object.getPrototypeOf(item);
|
|
434
|
+
if (itemProto !== Object.prototype && itemProto !== null) {
|
|
435
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'digest lockfile entry must be a plain object', itemPath);
|
|
436
|
+
}
|
|
437
|
+
const entryRec = item;
|
|
438
|
+
for (const key of Object.keys(entryRec)) {
|
|
439
|
+
if (FORBIDDEN_KEYS.has(key) || !allowedEntryKeys.has(key)) {
|
|
440
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `unknown digest lockfile entry field "${key}"`, itemPath);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const entryPath = normalizeRelativePath(entryRec['path'], `${itemPath}/path`);
|
|
444
|
+
const kind = entryRec['kind'];
|
|
445
|
+
if (kind !== 'file' && kind !== 'directory') {
|
|
446
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'digest lockfile entry kind must be "file" or "directory"', `${itemPath}/kind`);
|
|
447
|
+
}
|
|
448
|
+
const sha256 = entryRec['sha256'];
|
|
449
|
+
if (typeof sha256 !== 'string' || !SHA256_HEX_PATTERN.test(sha256)) {
|
|
450
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', 'digest lockfile entry sha256 must be a 64-character lowercase hex digest', `${itemPath}/sha256`);
|
|
451
|
+
}
|
|
452
|
+
const dedupeKey = `${kind}:${entryPath}`;
|
|
453
|
+
if (seen.has(dedupeKey)) {
|
|
454
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `duplicate digest lockfile entry "${entryPath}" (${kind})`, itemPath);
|
|
455
|
+
}
|
|
456
|
+
seen.add(dedupeKey);
|
|
457
|
+
entries.push(Object.freeze({ path: entryPath, kind, sha256 }));
|
|
458
|
+
}
|
|
459
|
+
entries.sort((a, b) => compareCodePoint(a.path, b.path) || compareCodePoint(a.kind, b.kind));
|
|
460
|
+
return Object.freeze({
|
|
461
|
+
version: 1,
|
|
462
|
+
taskpack: taskpackName,
|
|
463
|
+
entries: Object.freeze(entries),
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
/** Read and strictly validate `digests.lock.json` from inside `repoRoot`. */
|
|
467
|
+
export async function readDigestLockfile(repoRoot, lockfilePath) {
|
|
468
|
+
const normalized = normalizeRelativePath(lockfilePath, lockfilePath);
|
|
469
|
+
const { fullPath } = await resolveExistingSafeSubpath(repoRoot, normalized, normalized);
|
|
470
|
+
const bytes = await readBoundedControlFile(fullPath, DIGEST_LOCKFILE_MAX_BYTES, normalized);
|
|
471
|
+
let text;
|
|
472
|
+
try {
|
|
473
|
+
text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
474
|
+
}
|
|
475
|
+
catch {
|
|
476
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `digest lockfile "${normalized}" is not valid UTF-8`, normalized);
|
|
477
|
+
}
|
|
478
|
+
const parsed = parseJsonSubset(text, {
|
|
479
|
+
maxNodes: DIGEST_LOCKFILE_MAX_ENTRIES * 8,
|
|
480
|
+
maxDepth: 8,
|
|
481
|
+
maxCollection: DIGEST_LOCKFILE_MAX_ENTRIES,
|
|
482
|
+
maxString: DIGEST_LOCKFILE_MAX_BYTES,
|
|
483
|
+
diagPath: normalized,
|
|
484
|
+
});
|
|
485
|
+
return validateLockfileObject(parsed, normalized);
|
|
486
|
+
}
|
|
487
|
+
/** Atomically write a canonical deterministic `digests.lock.json` inside `repoRoot`, refusing symlink traversal. */
|
|
488
|
+
export async function writeDigestLockfile(repoRoot, lockfilePath, lockfile) {
|
|
489
|
+
const normalized = normalizeRelativePath(lockfilePath, lockfilePath);
|
|
490
|
+
const canonical = validateLockfileObject(lockfile, normalized);
|
|
491
|
+
const { resolvedRoot, realRoot } = await resolveSafeRepoRoot(repoRoot);
|
|
492
|
+
const segments = normalized.split('/');
|
|
493
|
+
const parentSegments = segments.slice(0, -1);
|
|
494
|
+
let current = resolvedRoot;
|
|
495
|
+
for (const segment of parentSegments) {
|
|
496
|
+
current = join(current, segment);
|
|
497
|
+
const st = await lstat(current).catch(() => null);
|
|
498
|
+
if (st !== null) {
|
|
499
|
+
if (st.isSymbolicLink()) {
|
|
500
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `lockfile parent "${normalized}" traverses a symbolic link`, normalized);
|
|
501
|
+
}
|
|
502
|
+
if (!st.isDirectory()) {
|
|
503
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `lockfile parent "${normalized}" is not a directory`, normalized);
|
|
504
|
+
}
|
|
505
|
+
const realCurrent = await realpath(current).catch(() => {
|
|
506
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `lockfile parent "${normalized}" cannot be resolved`, normalized);
|
|
507
|
+
});
|
|
508
|
+
if (!isContainedInRoot(realCurrent, realRoot)) {
|
|
509
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `lockfile parent "${normalized}" escapes repository root`, normalized);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
try {
|
|
514
|
+
await mkdir(current, { mode: 0o755 });
|
|
515
|
+
}
|
|
516
|
+
catch (error) {
|
|
517
|
+
const code = error?.code;
|
|
518
|
+
if (code === 'ELOOP') {
|
|
519
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `lockfile parent "${normalized}" traverses a symbolic link`, normalized);
|
|
520
|
+
}
|
|
521
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
522
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `failed to create lockfile parent directory for "${normalized}": ${detail}`, normalized);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const targetFullPath = join(resolvedRoot, ...segments);
|
|
527
|
+
const existing = await lstat(targetFullPath).catch(() => null);
|
|
528
|
+
if (existing !== null) {
|
|
529
|
+
if (existing.isSymbolicLink()) {
|
|
530
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `lockfile target "${normalized}" must not be a symbolic link`, normalized);
|
|
531
|
+
}
|
|
532
|
+
if (!existing.isFile()) {
|
|
533
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `lockfile target "${normalized}" must be a regular file`, normalized);
|
|
534
|
+
}
|
|
535
|
+
const realExisting = await realpath(targetFullPath).catch(() => {
|
|
536
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `lockfile target "${normalized}" cannot be resolved`, normalized);
|
|
537
|
+
});
|
|
538
|
+
if (!isContainedInRoot(realExisting, realRoot)) {
|
|
539
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `lockfile target "${normalized}" escapes repository root`, normalized);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
const serialized = `${JSON.stringify(canonical, null, 2)}\n`;
|
|
543
|
+
if (Buffer.byteLength(serialized, 'utf8') > DIGEST_LOCKFILE_MAX_BYTES) {
|
|
544
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `serialized digest lockfile exceeds ${DIGEST_LOCKFILE_MAX_BYTES} bytes`, normalized);
|
|
545
|
+
}
|
|
546
|
+
const parentDir = dirname(targetFullPath);
|
|
547
|
+
const tempPath = join(parentDir, `.digests-lock-${randomBytes(8).toString('hex')}.tmp`);
|
|
548
|
+
const noFollow = 'O_NOFOLLOW' in constants ? constants.O_NOFOLLOW : 0;
|
|
549
|
+
try {
|
|
550
|
+
const handle = await open(tempPath, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | noFollow, 0o644);
|
|
551
|
+
try {
|
|
552
|
+
await handle.writeFile(serialized, 'utf8');
|
|
553
|
+
}
|
|
554
|
+
finally {
|
|
555
|
+
await handle.close();
|
|
556
|
+
}
|
|
557
|
+
await rename(tempPath, targetFullPath);
|
|
558
|
+
}
|
|
559
|
+
catch (error) {
|
|
560
|
+
await unlink(tempPath).catch(() => undefined);
|
|
561
|
+
if (error instanceof TaskpackError)
|
|
562
|
+
throw error;
|
|
563
|
+
const code = error?.code;
|
|
564
|
+
if (code === 'ELOOP') {
|
|
565
|
+
throw new TaskpackError('TASKPACK_SCOPE_VIOLATION', `lockfile target "${normalized}" must not traverse or target symbolic links`, normalized);
|
|
566
|
+
}
|
|
567
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
568
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', `failed to atomically write digest lockfile "${normalized}": ${detail}`, normalized);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
function formatDigestRemediationHint(taskpack) {
|
|
572
|
+
let manifestTarget = '<taskpack.yaml>';
|
|
573
|
+
if (typeof taskpack.manifestPath === 'string' && taskpack.manifestPath.trim().length > 0) {
|
|
574
|
+
const cleaned = taskpack.manifestPath.trim().replaceAll('\\', '/').replace(/^(?:\.\/)+/, '');
|
|
575
|
+
const normalized = tryNormalizeRelativePath(cleaned);
|
|
576
|
+
if (normalized !== undefined) {
|
|
577
|
+
manifestTarget = normalized;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return `\nRun "loopwright digest sync --taskpack ${manifestTarget} --repo ." to refresh the lockfile.`;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Verify that `digests.lock.json` matches every tracked file and mounted check directory for `taskpack`.
|
|
584
|
+
* Fails closed with clear diagnostic details naming every drifted, missing, or extra file or directory.
|
|
585
|
+
*/
|
|
586
|
+
export async function verifyDigestLockfile(repoRoot, taskpack, controlRoot, lockfilePath, options = {}) {
|
|
587
|
+
const effectiveLockfilePath = lockfilePath !== undefined
|
|
588
|
+
? normalizeRelativePath(lockfilePath, lockfilePath)
|
|
589
|
+
: resolveDigestLockfilePath(taskpack, controlRoot);
|
|
590
|
+
const remediationHint = formatDigestRemediationHint(taskpack);
|
|
591
|
+
let expected;
|
|
592
|
+
try {
|
|
593
|
+
expected = await readDigestLockfile(repoRoot, effectiveLockfilePath);
|
|
594
|
+
}
|
|
595
|
+
catch (error) {
|
|
596
|
+
if (error instanceof TaskpackError && error.code === 'TASKPACK_SCOPE_VIOLATION') {
|
|
597
|
+
throw error;
|
|
598
|
+
}
|
|
599
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
600
|
+
return Object.freeze({
|
|
601
|
+
ok: false,
|
|
602
|
+
lockfilePath: effectiveLockfilePath,
|
|
603
|
+
reason: `digest lockfile "${effectiveLockfilePath}" could not be loaded: ${detail}${remediationHint}`,
|
|
604
|
+
drifts: Object.freeze([]),
|
|
605
|
+
computed: null,
|
|
606
|
+
expected: null,
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
let computed;
|
|
610
|
+
try {
|
|
611
|
+
computed = await computeTaskpackDigests(repoRoot, taskpack, controlRoot, options);
|
|
612
|
+
}
|
|
613
|
+
catch (error) {
|
|
614
|
+
if (error instanceof TaskpackError && error.code === 'TASKPACK_SCOPE_VIOLATION') {
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
618
|
+
return Object.freeze({
|
|
619
|
+
ok: false,
|
|
620
|
+
lockfilePath: effectiveLockfilePath,
|
|
621
|
+
reason: `failed to compute runtime digests for "${taskpack.metadata.name}": ${detail}${remediationHint}`,
|
|
622
|
+
drifts: Object.freeze([]),
|
|
623
|
+
computed: null,
|
|
624
|
+
expected,
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
if (expected.taskpack !== computed.taskpack) {
|
|
628
|
+
return Object.freeze({
|
|
629
|
+
ok: false,
|
|
630
|
+
lockfilePath: effectiveLockfilePath,
|
|
631
|
+
reason: `digest lockfile "${effectiveLockfilePath}" targets taskpack "${expected.taskpack}", expected "${computed.taskpack}"${remediationHint}`,
|
|
632
|
+
drifts: Object.freeze([]),
|
|
633
|
+
computed,
|
|
634
|
+
expected,
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
const expectedMap = new Map();
|
|
638
|
+
for (const entry of expected.entries) {
|
|
639
|
+
expectedMap.set(`${entry.kind}:${entry.path}`, entry);
|
|
640
|
+
}
|
|
641
|
+
const computedMap = new Map();
|
|
642
|
+
for (const entry of computed.entries) {
|
|
643
|
+
computedMap.set(`${entry.kind}:${entry.path}`, entry);
|
|
644
|
+
}
|
|
645
|
+
const drifts = [];
|
|
646
|
+
for (const [key, actual] of computedMap.entries()) {
|
|
647
|
+
const exp = expectedMap.get(key);
|
|
648
|
+
if (exp === undefined) {
|
|
649
|
+
drifts.push(Object.freeze({
|
|
650
|
+
path: actual.path,
|
|
651
|
+
kind: actual.kind,
|
|
652
|
+
status: 'missing',
|
|
653
|
+
expectedSha256: null,
|
|
654
|
+
actualSha256: actual.sha256,
|
|
655
|
+
}));
|
|
656
|
+
}
|
|
657
|
+
else if (exp.sha256 !== actual.sha256) {
|
|
658
|
+
drifts.push(Object.freeze({
|
|
659
|
+
path: actual.path,
|
|
660
|
+
kind: actual.kind,
|
|
661
|
+
status: 'drifted',
|
|
662
|
+
expectedSha256: exp.sha256,
|
|
663
|
+
actualSha256: actual.sha256,
|
|
664
|
+
}));
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
for (const [key, exp] of expectedMap.entries()) {
|
|
668
|
+
if (!computedMap.has(key)) {
|
|
669
|
+
drifts.push(Object.freeze({
|
|
670
|
+
path: exp.path,
|
|
671
|
+
kind: exp.kind,
|
|
672
|
+
status: 'extra',
|
|
673
|
+
expectedSha256: exp.sha256,
|
|
674
|
+
actualSha256: null,
|
|
675
|
+
}));
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (drifts.length === 0) {
|
|
679
|
+
return Object.freeze({
|
|
680
|
+
ok: true,
|
|
681
|
+
lockfilePath: effectiveLockfilePath,
|
|
682
|
+
computed,
|
|
683
|
+
expected,
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
drifts.sort((a, b) => compareCodePoint(a.path, b.path) || compareCodePoint(a.kind, b.kind));
|
|
687
|
+
const summaryParts = drifts.map(d => {
|
|
688
|
+
if (d.status === 'drifted') {
|
|
689
|
+
return `drifted ${d.kind} "${d.path}" (expected ${d.expectedSha256?.slice(0, 12)}, actual ${d.actualSha256?.slice(0, 12)})`;
|
|
690
|
+
}
|
|
691
|
+
if (d.status === 'missing') {
|
|
692
|
+
return `missing ${d.kind} "${d.path}" from lockfile`;
|
|
693
|
+
}
|
|
694
|
+
return `extra ${d.kind} "${d.path}" in lockfile`;
|
|
695
|
+
});
|
|
696
|
+
return Object.freeze({
|
|
697
|
+
ok: false,
|
|
698
|
+
lockfilePath: effectiveLockfilePath,
|
|
699
|
+
reason: `digest lockfile "${effectiveLockfilePath}" failed verification: ${summaryParts.join('; ')}${remediationHint}`,
|
|
700
|
+
drifts: Object.freeze(drifts),
|
|
701
|
+
computed,
|
|
702
|
+
expected,
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Convenience fail-closed guard that verifies `digests.lock.json` and throws
|
|
707
|
+
* `TaskpackError('TASKPACK_MANIFEST_INVALID', ...)` naming every drift when verification fails.
|
|
708
|
+
*/
|
|
709
|
+
export async function assertDigestLockfileVerified(repoRoot, taskpack, controlRoot, lockfilePath, options = {}) {
|
|
710
|
+
const result = await verifyDigestLockfile(repoRoot, taskpack, controlRoot, lockfilePath, options);
|
|
711
|
+
if (!result.ok) {
|
|
712
|
+
throw new TaskpackError('TASKPACK_MANIFEST_INVALID', result.reason, result.lockfilePath);
|
|
713
|
+
}
|
|
714
|
+
return result.computed;
|
|
715
|
+
}
|