@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,904 @@
|
|
|
1
|
+
import { LIMITS, bindSubject, identifyManifest } from '@loopwright/core';
|
|
2
|
+
import { canonical, freeze, hash, id, integer, isRecord, list, record, same, text, digestValue } from './schema.js';
|
|
3
|
+
import { parsePrivateJson } from './parser.js';
|
|
4
|
+
import { ControllerFailure, refuse } from './errors.js';
|
|
5
|
+
import { stateValue, checkedRef, ArtifactStore, streamVerifiedCasBlob } from './storage.js';
|
|
6
|
+
import { checkedRefusalRecord, checkedRefusalSubject, refusalSubject } from './refusal-record.js';
|
|
7
|
+
import { canonicalizeCandidateManifest, compareUtf16, overlayManifestBounds } from './source.js';
|
|
8
|
+
import { checkedVerdictText } from './submission.js';
|
|
9
|
+
import { decodeJsonPointer } from './handoff.js';
|
|
10
|
+
import { CONTROLLER_LIMITS } from './types.js';
|
|
11
|
+
export function phaseCheckpointId(runId, phase) {
|
|
12
|
+
return (phase.endsWith('.native') ? 'pi.' : 'controller.') + hash('loopwright.dev/controller/checkpoint/v1\0' + canonical({ runId, phase })).hex.slice(0, 40);
|
|
13
|
+
}
|
|
14
|
+
export function phaseSchedule(capacity) {
|
|
15
|
+
const phases = ['bootstrap'];
|
|
16
|
+
for (let attempt = 1; attempt <= capacity.A; attempt++)
|
|
17
|
+
for (const suffix of ['pre', 'native', 'post'])
|
|
18
|
+
phases.push('role.' + attempt + '.' + suffix);
|
|
19
|
+
for (let generation = 0; generation < capacity.V; generation++)
|
|
20
|
+
for (let slot = 0; slot < capacity.C; slot++)
|
|
21
|
+
for (const suffix of ['pre', 'post'])
|
|
22
|
+
phases.push('verify.' + generation + '.' + slot + '.' + suffix);
|
|
23
|
+
if (capacity.publication === true)
|
|
24
|
+
phases.push('publication.pre', 'publication.post');
|
|
25
|
+
phases.push('terminal.intent', 'terminal.result', 'terminal.observations');
|
|
26
|
+
if (capacity.publication === true)
|
|
27
|
+
phases.push('reconcile.result');
|
|
28
|
+
if (phases.length !== capacity.D)
|
|
29
|
+
refuse('ARTIFACT_INVALID', '', 'recovery');
|
|
30
|
+
return phases;
|
|
31
|
+
}
|
|
32
|
+
export function stableId(runId, nodeId, purpose, repair, ordinal) {
|
|
33
|
+
return 'attempt.' + hash('loopwright.dev/controller/attempt/v1\0' + canonical({ runId, nodeId, purpose, repair, ordinal })).hex.slice(0, 40);
|
|
34
|
+
}
|
|
35
|
+
export function verifierOperationId(runId, slot, generation) { return 'verify.' + hash('loopwright.dev/controller/verifier/v1\0' + canonical({ runId, slot, generation })).hex.slice(0, 40); }
|
|
36
|
+
/** Synchronous page walk: no renewal can interleave in this process; every collection shares one revision. */
|
|
37
|
+
export function journal(store) {
|
|
38
|
+
const walk = (reader) => {
|
|
39
|
+
let cursor = null, revision = -1;
|
|
40
|
+
const items = [];
|
|
41
|
+
do {
|
|
42
|
+
const page = stateValue(reader({ limit: 100, cursor }));
|
|
43
|
+
if (revision !== -1 && revision !== page.revision)
|
|
44
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
45
|
+
revision = page.revision;
|
|
46
|
+
items.push(...page.items);
|
|
47
|
+
cursor = page.next;
|
|
48
|
+
if (items.length > 16384)
|
|
49
|
+
refuse('OUTPUT_LIMIT', '', 'recovery');
|
|
50
|
+
} while (cursor !== null);
|
|
51
|
+
return { revision, items };
|
|
52
|
+
};
|
|
53
|
+
const requests = walk(input => store.listRequests(input)), operations = walk(input => store.listOperations(input)), checkpoints = walk(input => store.listCheckpoints(input));
|
|
54
|
+
const view = stateValue(store.inspect());
|
|
55
|
+
if ([requests.revision, operations.revision, checkpoints.revision].some(revision => revision !== view.revision))
|
|
56
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
57
|
+
return { view, requests: requests.items, operations: operations.items, checkpoints: checkpoints.items };
|
|
58
|
+
}
|
|
59
|
+
function watermarks(raw) { const value = record(raw, ['requests', 'operations']); integer(value.requests, 0, 4096); integer(value.operations, 0, 16384); }
|
|
60
|
+
function validateHandoffSourceRecord(raw) {
|
|
61
|
+
if (!isRecord(raw) || !Object.hasOwn(raw, 'kind'))
|
|
62
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
63
|
+
const kind = text(raw.kind, '', 16);
|
|
64
|
+
if (kind === 'artifact') {
|
|
65
|
+
const src = record(raw, ['kind', 'path']);
|
|
66
|
+
const p = text(src.path, '', LIMITS.path);
|
|
67
|
+
if (p.length === 0 || p.startsWith('/') || p.includes('\\') || /[\0\r\n]/.test(p) || p.split('/').some(s => s.length === 0 || s === '.' || s === '..')) {
|
|
68
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (kind === 'submission' || kind === 'verdict') {
|
|
73
|
+
record(raw, ['kind']);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
77
|
+
}
|
|
78
|
+
function validateHandoffSelectRecord(raw) {
|
|
79
|
+
if (!isRecord(raw) || !Object.hasOwn(raw, 'kind'))
|
|
80
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
81
|
+
const kind = text(raw.kind, '', 32);
|
|
82
|
+
if (kind === 'markdown_heading') {
|
|
83
|
+
const hasSub = Object.hasOwn(raw, 'includeSubheadings');
|
|
84
|
+
const sel = record(raw, hasSub ? ['kind', 'heading', 'includeSubheadings'] : ['kind', 'heading']);
|
|
85
|
+
const heading = text(sel.heading, '', LIMITS.handoffHeading);
|
|
86
|
+
if (heading.trim().length === 0 || /[\0\r\n]/.test(heading))
|
|
87
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
88
|
+
if (hasSub && typeof sel.includeSubheadings !== 'boolean')
|
|
89
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (kind === 'json_pointer') {
|
|
93
|
+
const sel = record(raw, ['kind', 'pointers']);
|
|
94
|
+
const ptrs = list(sel.pointers, '', LIMITS.handoffPointers).map(item => text(item, '', LIMITS.handoffPointer));
|
|
95
|
+
if (ptrs.length < 1 || new Set(ptrs).size !== ptrs.length)
|
|
96
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
97
|
+
for (const ptr of ptrs)
|
|
98
|
+
decodeJsonPointer(ptr, '', 'recovery');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (kind === 'full') {
|
|
102
|
+
record(raw, ['kind']);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
106
|
+
}
|
|
107
|
+
function checkedProgress(raw, plan, lock) {
|
|
108
|
+
if (!isRecord(raw))
|
|
109
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
110
|
+
const hasPublication = Object.hasOwn(raw, 'publication');
|
|
111
|
+
const hasReworkEpoch = Object.hasOwn(raw, 'reworkEpoch');
|
|
112
|
+
const hasReworkCounts = Object.hasOwn(raw, 'reworkCounts');
|
|
113
|
+
const hasNodeSubmissions = Object.hasOwn(raw, 'nodeSubmissions');
|
|
114
|
+
const hasNodeCandidates = Object.hasOwn(raw, 'nodeCandidates');
|
|
115
|
+
const hasStepVerdicts = Object.hasOwn(raw, 'stepVerdicts');
|
|
116
|
+
const value = record(raw, [
|
|
117
|
+
'version', 'runId', 'lockHash', 'sequence', 'previous', 'stage', 'nodes', 'attempts', 'nativeCheckpoints',
|
|
118
|
+
'submission', 'publication', 'candidate', 'failures', 'verifierReceipts', 'verifierRefusals', 'eventSequence', 'terminalIntent',
|
|
119
|
+
...(hasReworkEpoch ? ['reworkEpoch'] : []),
|
|
120
|
+
...(hasReworkCounts ? ['reworkCounts'] : []),
|
|
121
|
+
...(hasNodeSubmissions ? ['nodeSubmissions'] : []),
|
|
122
|
+
...(hasNodeCandidates ? ['nodeCandidates'] : []),
|
|
123
|
+
...(hasStepVerdicts ? ['stepVerdicts'] : []),
|
|
124
|
+
]);
|
|
125
|
+
if (value.version !== 2 || value.runId !== lock.spec.runId || !same(value.lockHash, lock.spec.lockHash))
|
|
126
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
127
|
+
integer(value.sequence, 1, 256);
|
|
128
|
+
integer(value.eventSequence, 0, Number.MAX_SAFE_INTEGER);
|
|
129
|
+
if (value.previous !== null)
|
|
130
|
+
checkedRef(value.previous);
|
|
131
|
+
if (value.submission !== null)
|
|
132
|
+
checkedRef(value.submission);
|
|
133
|
+
const currentReworkEpoch = hasReworkEpoch ? integer(value.reworkEpoch, 0, 128) : 0;
|
|
134
|
+
if (hasReworkCounts) {
|
|
135
|
+
if (!isRecord(value.reworkCounts))
|
|
136
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
137
|
+
const countKeys = Object.keys(value.reworkCounts);
|
|
138
|
+
if (countKeys.length > 16)
|
|
139
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
140
|
+
let sumReworks = 0;
|
|
141
|
+
for (const key of countKeys) {
|
|
142
|
+
const dagNode = plan.orderedDAG.find(item => item.id === key);
|
|
143
|
+
if (!dagNode?.onRework)
|
|
144
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
145
|
+
sumReworks += integer(value.reworkCounts[key], 0, dagNode.onRework.maxReworks);
|
|
146
|
+
}
|
|
147
|
+
if (sumReworks !== currentReworkEpoch)
|
|
148
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
149
|
+
}
|
|
150
|
+
else if (currentReworkEpoch !== 0) {
|
|
151
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
152
|
+
}
|
|
153
|
+
if (hasNodeSubmissions) {
|
|
154
|
+
if (!isRecord(value.nodeSubmissions))
|
|
155
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
156
|
+
const subKeys = Object.keys(value.nodeSubmissions);
|
|
157
|
+
if (subKeys.length > 16)
|
|
158
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
159
|
+
for (const key of subKeys) {
|
|
160
|
+
if (!plan.orderedDAG.some(item => item.id === key && item.kind === 'agent'))
|
|
161
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
162
|
+
checkedRef(value.nodeSubmissions[key]);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
let publication = { status: 'idle', operationId: null, receipt: null };
|
|
166
|
+
if (hasPublication) {
|
|
167
|
+
const item = record(value.publication, ['status', 'operationId', 'receipt']);
|
|
168
|
+
if (!['idle', 'pending', 'confirmed', 'failed', 'unresolved'].includes(text(item.status)))
|
|
169
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
170
|
+
if (item.status === 'idle') {
|
|
171
|
+
if (item.operationId !== null || item.receipt !== null)
|
|
172
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
id(item.operationId, '/publication/operationId');
|
|
176
|
+
if (['confirmed', 'failed'].includes(text(item.status)) && item.receipt === null)
|
|
177
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
178
|
+
if (item.receipt !== null)
|
|
179
|
+
checkedRef(item.receipt);
|
|
180
|
+
}
|
|
181
|
+
publication = { status: item.status, operationId: item.operationId, receipt: item.receipt };
|
|
182
|
+
}
|
|
183
|
+
const stage = record(value.stage, ['kind', 'phase', 'capacity', 'consumed', 'watermarks']);
|
|
184
|
+
const kinds = ['bootstrap', 'role_pre', 'role_post', 'verifier_pre', 'verifier_post', 'publication_pre', 'publication_post', 'terminal_intent', 'terminal_result', 'terminal_observations', 'reconcile_result'];
|
|
185
|
+
if (!kinds.includes(text(stage.kind)) || !same(stage.capacity, plan.capacity))
|
|
186
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
187
|
+
watermarks(stage.watermarks);
|
|
188
|
+
const schedule = phaseSchedule(plan.capacity), consumed = list(stage.consumed, '', 256).map(item => text(item, '', 64));
|
|
189
|
+
if (!schedule.includes(text(stage.phase)) || consumed.at(-1) !== stage.phase || consumed.length !== value.sequence || new Set(consumed).size !== consumed.length || consumed.some(phase => !schedule.includes(phase)))
|
|
190
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
191
|
+
const phase = text(stage.phase), expectedKind = phase === 'bootstrap' ? 'bootstrap' : phase.startsWith('role.') ? phase.endsWith('.pre') ? 'role_pre' : 'role_post'
|
|
192
|
+
: phase.startsWith('verify.') ? phase.endsWith('.pre') ? 'verifier_pre' : 'verifier_post' : phase.replace('.', '_');
|
|
193
|
+
if (phase.endsWith('.native') || stage.kind !== expectedKind || consumed[0] !== 'bootstrap')
|
|
194
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
195
|
+
const nodes = list(value.nodes, '', 16).map(node => record(node, ['id', 'state']));
|
|
196
|
+
if (nodes.length !== plan.orderedDAG.length || new Set(nodes.map(node => node.id)).size !== nodes.length || nodes.some(node => !plan.orderedDAG.some(item => item.id === node.id) || !['pending', 'running', 'completed', 'failed', 'blocked', 'not_run'].includes(text(node.state))))
|
|
197
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
198
|
+
const attempts = list(value.attempts, '', 64);
|
|
199
|
+
if (attempts.length > plan.capacity.A)
|
|
200
|
+
refuse('ATTEMPT_LIMIT', '', 'recovery');
|
|
201
|
+
for (const [index, rawAttempt] of attempts.entries()) {
|
|
202
|
+
const hasAttemptEpoch = isRecord(rawAttempt) && Object.hasOwn(rawAttempt, 'reworkEpoch');
|
|
203
|
+
const hasActivatedResourceIds = isRecord(rawAttempt) && Object.hasOwn(rawAttempt, 'activatedResourceIds');
|
|
204
|
+
const hasHandoffExtracts = isRecord(rawAttempt) && Object.hasOwn(rawAttempt, 'handoffExtracts');
|
|
205
|
+
const attempt = record(rawAttempt, [
|
|
206
|
+
'ordinal',
|
|
207
|
+
'id',
|
|
208
|
+
'nodeId',
|
|
209
|
+
'nativeStepId',
|
|
210
|
+
'sessionId',
|
|
211
|
+
'purpose',
|
|
212
|
+
'repair',
|
|
213
|
+
'command',
|
|
214
|
+
'before',
|
|
215
|
+
'finished',
|
|
216
|
+
...(hasAttemptEpoch ? ['reworkEpoch'] : []),
|
|
217
|
+
...(hasActivatedResourceIds ? ['activatedResourceIds'] : []),
|
|
218
|
+
...(hasHandoffExtracts ? ['handoffExtracts'] : []),
|
|
219
|
+
]);
|
|
220
|
+
if (hasAttemptEpoch)
|
|
221
|
+
integer(attempt.reworkEpoch, 0, currentReworkEpoch);
|
|
222
|
+
if (attempt.ordinal !== index + 1 || !plan.orderedDAG.some(node => node.id === attempt.nodeId && node.kind === 'agent') || !['task', 'reviewer', 'compaction'].includes(text(attempt.purpose)) || !['none', 'format', 'implementation'].includes(text(attempt.repair))
|
|
223
|
+
|| attempt.id !== stableId(lock.spec.runId, text(attempt.nodeId), text(attempt.purpose), text(attempt.repair), index + 1))
|
|
224
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
225
|
+
const node = plan.orderedDAG.find(node => node.id === attempt.nodeId), nativeStep = plan.orderedDAG.find(node => node.id === attempt.nativeStepId);
|
|
226
|
+
if (!nativeStep || nativeStep.kind !== 'agent' || nativeStep.roleId !== node.roleId || !/^[a-z][a-z0-9._-]{0,63}$/.test(text(attempt.sessionId)))
|
|
227
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
228
|
+
const plannedRole = plan.roles.find(r => r.roleId === node.roleId);
|
|
229
|
+
if (!plannedRole)
|
|
230
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
231
|
+
let activeResourceCount = 0;
|
|
232
|
+
if (hasActivatedResourceIds) {
|
|
233
|
+
if (attempt.purpose === 'compaction')
|
|
234
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
235
|
+
const ids = list(attempt.activatedResourceIds, '', LIMITS.resources).map(item => id(item));
|
|
236
|
+
const allowedRoleResIds = plannedRole.policy.resources.slice(1).map(r => r.id);
|
|
237
|
+
const indexByResId = new Map(allowedRoleResIds.map((resId, pos) => [resId, pos]));
|
|
238
|
+
let prevPos = -1;
|
|
239
|
+
for (const resId of ids) {
|
|
240
|
+
const pos = indexByResId.get(resId);
|
|
241
|
+
if (pos === undefined || pos <= prevPos)
|
|
242
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
243
|
+
prevPos = pos;
|
|
244
|
+
}
|
|
245
|
+
activeResourceCount = ids.length;
|
|
246
|
+
}
|
|
247
|
+
if (hasHandoffExtracts) {
|
|
248
|
+
if (attempt.purpose === 'compaction' || attempt.repair === 'format' || !node.handoffs) {
|
|
249
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
250
|
+
}
|
|
251
|
+
const rawExtracts = list(attempt.handoffExtracts, '', LIMITS.handoffsPerStep);
|
|
252
|
+
if (rawExtracts.length !== node.handoffs.length)
|
|
253
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
254
|
+
let totalExtractBytes = 0;
|
|
255
|
+
let presentExtractCount = 0;
|
|
256
|
+
const seenExtractIds = new Set();
|
|
257
|
+
for (const rawExt of rawExtracts) {
|
|
258
|
+
if (!isRecord(rawExt))
|
|
259
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
260
|
+
const hasOmittedReason = Object.hasOwn(rawExt, 'omittedReason');
|
|
261
|
+
const ext = record(rawExt, [
|
|
262
|
+
'id',
|
|
263
|
+
'fromStep',
|
|
264
|
+
'fromAttemptId',
|
|
265
|
+
'reworkEpoch',
|
|
266
|
+
'source',
|
|
267
|
+
'select',
|
|
268
|
+
'status',
|
|
269
|
+
'sourceSha256',
|
|
270
|
+
'extractSha256',
|
|
271
|
+
'byteLength',
|
|
272
|
+
'truncated',
|
|
273
|
+
'artifact',
|
|
274
|
+
...(hasOmittedReason ? ['omittedReason'] : []),
|
|
275
|
+
]);
|
|
276
|
+
const extId = id(ext.id);
|
|
277
|
+
if (seenExtractIds.has(extId))
|
|
278
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
279
|
+
seenExtractIds.add(extId);
|
|
280
|
+
const fromStep = id(ext.fromStep);
|
|
281
|
+
if (!plan.orderedDAG.some(item => item.id === fromStep))
|
|
282
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
283
|
+
if (ext.fromAttemptId !== null)
|
|
284
|
+
id(ext.fromAttemptId);
|
|
285
|
+
integer(ext.reworkEpoch, 0, currentReworkEpoch);
|
|
286
|
+
validateHandoffSourceRecord(ext.source);
|
|
287
|
+
validateHandoffSelectRecord(ext.select);
|
|
288
|
+
if (typeof ext.truncated !== 'boolean')
|
|
289
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
290
|
+
const status = text(ext.status, '', 16);
|
|
291
|
+
if (status === 'extracted') {
|
|
292
|
+
if (hasOmittedReason)
|
|
293
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
294
|
+
const srcHex = text(ext.sourceSha256, '', 64);
|
|
295
|
+
const extHex = text(ext.extractSha256, '', 64);
|
|
296
|
+
if (!/^[0-9a-f]{64}$/.test(srcHex) || !/^[0-9a-f]{64}$/.test(extHex))
|
|
297
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
298
|
+
const byteLen = integer(ext.byteLength, 0, LIMITS.handoffMaxBytes);
|
|
299
|
+
totalExtractBytes += byteLen;
|
|
300
|
+
if (totalExtractBytes > LIMITS.handoffAggregateBytes)
|
|
301
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
302
|
+
const art = checkedRef(ext.artifact);
|
|
303
|
+
if (art.byteLength !== byteLen || art.digest.hex !== extHex || art.uri !== 'cas://sha256/' + extHex) {
|
|
304
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
305
|
+
}
|
|
306
|
+
presentExtractCount += 1;
|
|
307
|
+
}
|
|
308
|
+
else if (status === 'omitted') {
|
|
309
|
+
if (!hasOmittedReason || !['source_missing', 'heading_missing', 'pointer_missing'].includes(text(ext.omittedReason, '', 32))) {
|
|
310
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
311
|
+
}
|
|
312
|
+
if (ext.sourceSha256 !== null && !/^[0-9a-f]{64}$/.test(text(ext.sourceSha256, '', 64))) {
|
|
313
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
314
|
+
}
|
|
315
|
+
if (ext.extractSha256 !== null || ext.byteLength !== 0 || ext.truncated !== false || ext.artifact !== null) {
|
|
316
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (activeResourceCount + presentExtractCount > CONTROLLER_LIMITS.maxStepContextFiles) {
|
|
324
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
checkedRef(attempt.command);
|
|
328
|
+
watermarks(attempt.before);
|
|
329
|
+
if (attempt.finished !== null) {
|
|
330
|
+
const finished = record(attempt.finished, ['after', 'outcome', 'nativeCheckpointId']);
|
|
331
|
+
watermarks(finished.after);
|
|
332
|
+
checkedRef(finished.outcome);
|
|
333
|
+
if (finished.nativeCheckpointId !== null && finished.nativeCheckpointId !== phaseCheckpointId(lock.spec.runId, 'role.' + (index + 1) + '.native'))
|
|
334
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
335
|
+
}
|
|
336
|
+
else if (index !== attempts.length - 1)
|
|
337
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
338
|
+
}
|
|
339
|
+
const typedAttempts = attempts;
|
|
340
|
+
if (hasNodeCandidates) {
|
|
341
|
+
if (!isRecord(value.nodeCandidates))
|
|
342
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
343
|
+
const candKeys = Object.keys(value.nodeCandidates);
|
|
344
|
+
if (candKeys.length > CONTROLLER_LIMITS.maxCompiledDagSteps)
|
|
345
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
346
|
+
for (const stepKey of candKeys) {
|
|
347
|
+
const dagNode = plan.orderedDAG.find(item => item.id === stepKey && item.kind === 'agent' && item.handler.implementation !== 'pi.compact.v1');
|
|
348
|
+
if (!dagNode)
|
|
349
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
350
|
+
const snap = record(value.nodeCandidates[stepKey], ['attemptId', 'reworkEpoch', 'manifest', 'digest', 'workspace']);
|
|
351
|
+
const snapEpoch = integer(snap.reworkEpoch, 0, currentReworkEpoch);
|
|
352
|
+
const matchedAttempt = typedAttempts.find(item => item.id === snap.attemptId);
|
|
353
|
+
if (!matchedAttempt
|
|
354
|
+
|| matchedAttempt.finished === null
|
|
355
|
+
|| matchedAttempt.finished.nativeCheckpointId === null
|
|
356
|
+
|| matchedAttempt.nodeId !== stepKey
|
|
357
|
+
|| (matchedAttempt.reworkEpoch ?? 0) !== snapEpoch) {
|
|
358
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
359
|
+
}
|
|
360
|
+
checkedRef(snap.manifest);
|
|
361
|
+
digestValue(snap.digest);
|
|
362
|
+
checkedRef(snap.workspace);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const taskOrdinary = typedAttempts.filter(attempt => attempt.repair === 'none' && attempt.purpose === 'task');
|
|
366
|
+
const implCount = typedAttempts.filter(attempt => attempt.repair === 'implementation').length;
|
|
367
|
+
const reviewerCounts = new Map();
|
|
368
|
+
const awaitingRepairBeforeNextReview = new Set();
|
|
369
|
+
let invalidReviewerSequence = false;
|
|
370
|
+
let seenEpoch = 0;
|
|
371
|
+
for (const attempt of typedAttempts) {
|
|
372
|
+
const attemptEpoch = attempt.reworkEpoch ?? 0;
|
|
373
|
+
if (attemptEpoch < seenEpoch || attemptEpoch > currentReworkEpoch)
|
|
374
|
+
invalidReviewerSequence = true;
|
|
375
|
+
if (attemptEpoch > seenEpoch) {
|
|
376
|
+
seenEpoch = attemptEpoch;
|
|
377
|
+
awaitingRepairBeforeNextReview.clear();
|
|
378
|
+
}
|
|
379
|
+
if (attempt.repair === 'implementation')
|
|
380
|
+
awaitingRepairBeforeNextReview.clear();
|
|
381
|
+
else if (attempt.repair === 'none' && attempt.purpose === 'reviewer') {
|
|
382
|
+
if (awaitingRepairBeforeNextReview.has(attempt.nodeId))
|
|
383
|
+
invalidReviewerSequence = true;
|
|
384
|
+
awaitingRepairBeforeNextReview.add(attempt.nodeId);
|
|
385
|
+
reviewerCounts.set(attempt.nodeId, (reviewerCounts.get(attempt.nodeId) ?? 0) + 1);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (new Set(taskOrdinary.map(attempt => String(attempt.reworkEpoch ?? 0) + ':' + attempt.nodeId)).size !== taskOrdinary.length || invalidReviewerSequence
|
|
389
|
+
|| [...reviewerCounts.values()].some(count => count > 1 + implCount + currentReworkEpoch)
|
|
390
|
+
|| implCount > plan.budgets.maxImplementationRepairs
|
|
391
|
+
|| typedAttempts.filter(attempt => attempt.repair === 'format').length > plan.budgets.maxFormatRepairs)
|
|
392
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
393
|
+
if (phase.startsWith('role.')) {
|
|
394
|
+
const ordinal = Number(phase.split('.')[1]), attempt = typedAttempts.at(-1);
|
|
395
|
+
if (!attempt || attempt.ordinal !== ordinal || phase.endsWith('.pre') !== (attempt.finished === null) || phase.endsWith('.post') && !consumed.includes('role.' + ordinal + '.pre'))
|
|
396
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
397
|
+
}
|
|
398
|
+
const candidate = record(value.candidate, ['manifest', 'digest', 'generation', 'workspace', 'privateSession']);
|
|
399
|
+
checkedRef(candidate.manifest);
|
|
400
|
+
digestValue(candidate.digest);
|
|
401
|
+
checkedRef(candidate.workspace);
|
|
402
|
+
if (candidate.privateSession !== null)
|
|
403
|
+
checkedRef(candidate.privateSession);
|
|
404
|
+
integer(candidate.generation, 0, plan.capacity.V - 1);
|
|
405
|
+
const native = list(value.nativeCheckpoints, '', plan.capacity.A).map(item => record(item, ['attemptId', 'checkpointId', 'outcome']));
|
|
406
|
+
if (new Set(native.map(item => item.checkpointId)).size !== native.length)
|
|
407
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
408
|
+
for (const item of native) {
|
|
409
|
+
const attempt = typedAttempts.find(attempt => attempt.id === item.attemptId);
|
|
410
|
+
if (!attempt || attempt.finished === null || item.checkpointId !== phaseCheckpointId(lock.spec.runId, 'role.' + attempt.ordinal + '.native') || attempt.finished.nativeCheckpointId !== item.checkpointId || !same(attempt.finished.outcome, item.outcome))
|
|
411
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
412
|
+
checkedRef(item.outcome);
|
|
413
|
+
}
|
|
414
|
+
if (native.length !== typedAttempts.filter(attempt => attempt.finished !== null && attempt.finished.nativeCheckpointId !== null).length)
|
|
415
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
416
|
+
const failures = list(value.failures, '', 16).map(rawFailure => record(rawFailure, ['signature', 'count', 'generation', 'evidence']));
|
|
417
|
+
for (const failure of failures) {
|
|
418
|
+
digestValue(failure.signature);
|
|
419
|
+
integer(failure.count, 1, 2);
|
|
420
|
+
integer(failure.generation, 0, plan.capacity.V - 1);
|
|
421
|
+
if (failure.evidence !== null)
|
|
422
|
+
checkedRef(failure.evidence);
|
|
423
|
+
}
|
|
424
|
+
if (new Set(failures.map(failure => canonical(failure.signature))).size !== failures.length)
|
|
425
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
426
|
+
const receipts = list(value.verifierReceipts, '', plan.capacity.J).map(item => {
|
|
427
|
+
const hasReceiptEpoch = isRecord(item) && Object.hasOwn(item, 'reworkEpoch');
|
|
428
|
+
const row = record(item, ['slot', 'generation', 'operationId', 'producerNonce', 'output', 'receipt', ...(hasReceiptEpoch ? ['reworkEpoch'] : [])]);
|
|
429
|
+
if (hasReceiptEpoch)
|
|
430
|
+
integer(row.reworkEpoch, 0, currentReworkEpoch);
|
|
431
|
+
return row;
|
|
432
|
+
});
|
|
433
|
+
if (new Set(receipts.map(item => item.slot + ':' + item.generation)).size !== receipts.length)
|
|
434
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
435
|
+
for (const item of receipts) {
|
|
436
|
+
if (!plan.verifierSlots.some(slot => slot.id === item.slot))
|
|
437
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
438
|
+
integer(item.generation, 0, plan.capacity.V - 1);
|
|
439
|
+
if (item.operationId !== verifierOperationId(lock.spec.runId, text(item.slot), item.generation) || !/^[a-f0-9]{32}$/.test(text(item.producerNonce)) || (item.output === null) !== (item.receipt === null))
|
|
440
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
441
|
+
if (item.output !== null)
|
|
442
|
+
checkedRef(item.output);
|
|
443
|
+
if (item.receipt !== null)
|
|
444
|
+
checkedRef(item.receipt);
|
|
445
|
+
}
|
|
446
|
+
const typedStepVerdicts = [];
|
|
447
|
+
if (hasStepVerdicts) {
|
|
448
|
+
const rawVerdicts = list(value.stepVerdicts, '', 64);
|
|
449
|
+
const seenKeys = new Set();
|
|
450
|
+
for (const rawVerdict of rawVerdicts) {
|
|
451
|
+
const entry = record(rawVerdict, ['attemptId', 'stepId', 'roleId', 'reworkEpoch', 'generation', 'raw', 'verdict', 'summaryPreview', 'findingCount']);
|
|
452
|
+
const stepId = text(entry.stepId, '', 64);
|
|
453
|
+
const dagNode = plan.orderedDAG.find(item => item.id === stepId);
|
|
454
|
+
if (!dagNode)
|
|
455
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
456
|
+
const entryEpoch = integer(entry.reworkEpoch, 0, currentReworkEpoch);
|
|
457
|
+
const entryGen = integer(entry.generation, 0, plan.capacity.V - 1);
|
|
458
|
+
checkedRef(entry.raw);
|
|
459
|
+
const verdictDisposition = text(entry.verdict, '', 16);
|
|
460
|
+
if (!['pass', 'rework', 'fail', 'human'].includes(verdictDisposition))
|
|
461
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
462
|
+
checkedVerdictText(entry.summaryPreview, 256, false, 'RECOVERY_REQUIRED', 'recovery');
|
|
463
|
+
integer(entry.findingCount, 0, LIMITS.findings);
|
|
464
|
+
if (dagNode.kind === 'agent') {
|
|
465
|
+
const matchedAttempt = typedAttempts.find(item => item.id === entry.attemptId);
|
|
466
|
+
if (!matchedAttempt ||
|
|
467
|
+
matchedAttempt.finished === null ||
|
|
468
|
+
matchedAttempt.nodeId !== stepId ||
|
|
469
|
+
(matchedAttempt.reworkEpoch ?? 0) !== entryEpoch ||
|
|
470
|
+
dagNode.roleId !== entry.roleId) {
|
|
471
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
472
|
+
}
|
|
473
|
+
const key = 'attempt:' + matchedAttempt.id;
|
|
474
|
+
if (seenKeys.has(key))
|
|
475
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
476
|
+
seenKeys.add(key);
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
if (!dagNode.onRework || entry.attemptId !== null || entry.roleId !== null || verdictDisposition !== 'rework') {
|
|
480
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
481
|
+
}
|
|
482
|
+
const slot = plan.verifierSlots.find(item => item.handler.id === dagNode.handler.id);
|
|
483
|
+
const matchedReceipt = slot
|
|
484
|
+
? receipts.find(item => item.slot === slot.id && item.receipt !== null && (item.generation === entryGen || item.generation + 1 === entryGen))
|
|
485
|
+
: undefined;
|
|
486
|
+
if (!matchedReceipt)
|
|
487
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
488
|
+
const key = 'check:' + stepId + ':' + entryEpoch + ':' + entryGen;
|
|
489
|
+
if (seenKeys.has(key))
|
|
490
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
491
|
+
seenKeys.add(key);
|
|
492
|
+
}
|
|
493
|
+
typedStepVerdicts.push(entry);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const refusals = list(value.verifierRefusals, '', plan.capacity.J).map(item => record(item, ['slot', 'generation', 'prospectiveOperationId', 'producerNonce', 'subject', 'record']));
|
|
497
|
+
if (receipts.length + refusals.length > plan.capacity.J || new Set([...receipts, ...refusals].map(item => item.slot + ':' + item.generation)).size !== receipts.length + refusals.length)
|
|
498
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
499
|
+
for (const item of refusals) {
|
|
500
|
+
if (!plan.verifierSlots.some(slot => slot.id === item.slot))
|
|
501
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
502
|
+
integer(item.generation, 0, candidate.generation);
|
|
503
|
+
if (item.prospectiveOperationId !== verifierOperationId(lock.spec.runId, text(item.slot), item.generation) || !/^[a-f0-9]{32}$/.test(text(item.producerNonce)) || checkedRef(item.record).byteLength > 65536)
|
|
504
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
505
|
+
checkedRefusalSubject(item.subject, lock);
|
|
506
|
+
}
|
|
507
|
+
if (phase.startsWith('verify.')) {
|
|
508
|
+
const [, generation, ordinal] = phase.split('.'), slot = plan.verifierSlots[Number(ordinal)];
|
|
509
|
+
const gen = Number(generation);
|
|
510
|
+
const receipt = receipts.find(item => item.slot === slot.id && item.generation === gen), refusal = refusals.find(item => item.slot === slot.id && item.generation === gen);
|
|
511
|
+
const checkReworkAdvanced = phase.endsWith('.post') &&
|
|
512
|
+
gen + 1 === candidate.generation &&
|
|
513
|
+
typedStepVerdicts.some(item => item.attemptId === null &&
|
|
514
|
+
item.generation === candidate.generation &&
|
|
515
|
+
item.verdict === 'rework' &&
|
|
516
|
+
plan.orderedDAG.some(node => node.id === item.stepId && node.kind === 'check' && node.handler.id === slot.handler.id));
|
|
517
|
+
if ((gen !== candidate.generation && !checkReworkAdvanced) || !receipt && !refusal || phase.endsWith('.post') && (receipt?.receipt === null || !consumed.includes('verify.' + generation + '.' + ordinal + '.pre')))
|
|
518
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
519
|
+
}
|
|
520
|
+
if (value.terminalIntent !== null) {
|
|
521
|
+
const terminal = record(value.terminalIntent, ['primary', 'result', 'observations']);
|
|
522
|
+
text(terminal.primary, '', 64);
|
|
523
|
+
if (terminal.result !== null)
|
|
524
|
+
checkedRef(terminal.result);
|
|
525
|
+
if (terminal.observations !== null)
|
|
526
|
+
checkedRef(terminal.observations);
|
|
527
|
+
}
|
|
528
|
+
if (consumed.includes('publication.pre') && publication.status === 'idle')
|
|
529
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
530
|
+
if (consumed.includes('publication.post') && ['idle', 'pending'].includes(publication.status))
|
|
531
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
532
|
+
return { ...raw, publication };
|
|
533
|
+
}
|
|
534
|
+
export function validateProgress(raw, plan, lock) {
|
|
535
|
+
try {
|
|
536
|
+
return checkedProgress(raw, plan, lock);
|
|
537
|
+
}
|
|
538
|
+
catch (error) {
|
|
539
|
+
if (error instanceof ControllerFailure && ['RECOVERY_REQUIRED', 'ARTIFACT_INVALID', 'ATTEMPT_LIMIT', 'OUTPUT_LIMIT'].includes(error.diagnostic.code))
|
|
540
|
+
throw error;
|
|
541
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
function extension(previous, current, plan) {
|
|
545
|
+
if (!previous) {
|
|
546
|
+
if (current.stage.phase !== 'bootstrap' ||
|
|
547
|
+
current.previous !== null ||
|
|
548
|
+
current.attempts.length ||
|
|
549
|
+
current.verifierRefusals.length ||
|
|
550
|
+
current.candidate.generation !== 0 ||
|
|
551
|
+
(current.reworkEpoch ?? 0) !== 0 ||
|
|
552
|
+
Object.keys(current.nodeCandidates ?? {}).length !== 0 ||
|
|
553
|
+
(current.stepVerdicts?.length ?? 0) !== 0) {
|
|
554
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
555
|
+
}
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
if (current.sequence <= previous.sequence || current.attempts.length < previous.attempts.length || current.eventSequence < previous.eventSequence || !same(current.stage.consumed.slice(0, previous.stage.consumed.length), previous.stage.consumed))
|
|
559
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
560
|
+
for (const [index, prior] of previous.attempts.entries()) {
|
|
561
|
+
const next = current.attempts[index];
|
|
562
|
+
if (!same({ ...prior, finished: null }, { ...next, finished: null }) || prior.finished !== null && !same(prior, next))
|
|
563
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
564
|
+
}
|
|
565
|
+
const prevEpoch = previous.reworkEpoch ?? 0;
|
|
566
|
+
const currEpoch = current.reworkEpoch ?? 0;
|
|
567
|
+
if (currEpoch < prevEpoch || currEpoch > prevEpoch + 1)
|
|
568
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
569
|
+
const reworked = currEpoch === prevEpoch + 1;
|
|
570
|
+
const changed = !same(previous.candidate.digest, current.candidate.digest);
|
|
571
|
+
if (current.candidate.generation !== previous.candidate.generation + (changed || reworked ? 1 : 0))
|
|
572
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
573
|
+
if (changed && (current.stage.kind !== 'role_post' || current.attempts.at(-1)?.repair === 'format' || current.attempts.at(-1)?.purpose === 'compaction'))
|
|
574
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
575
|
+
if (reworked) {
|
|
576
|
+
const validRoleRework = current.stage.kind === 'role_post' && current.attempts.at(-1)?.repair !== 'format' && current.attempts.at(-1)?.purpose !== 'compaction';
|
|
577
|
+
const validCheckRework = current.stage.kind === 'verifier_post' && !changed;
|
|
578
|
+
if (!validRoleRework && !validCheckRework)
|
|
579
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
580
|
+
}
|
|
581
|
+
const prevCounts = previous.reworkCounts ?? {};
|
|
582
|
+
const currCounts = current.reworkCounts ?? {};
|
|
583
|
+
for (const [key, count] of Object.entries(prevCounts)) {
|
|
584
|
+
if ((currCounts[key] ?? 0) < count)
|
|
585
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
586
|
+
}
|
|
587
|
+
const prevVerdicts = previous.stepVerdicts ?? [];
|
|
588
|
+
const currVerdicts = current.stepVerdicts ?? [];
|
|
589
|
+
if (currVerdicts.length < prevVerdicts.length || !same(currVerdicts.slice(0, prevVerdicts.length), prevVerdicts))
|
|
590
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
591
|
+
if (current.verifierReceipts.length < previous.verifierReceipts.length || !same(current.nativeCheckpoints.slice(0, previous.nativeCheckpoints.length), previous.nativeCheckpoints))
|
|
592
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
593
|
+
for (const [index, prior] of previous.verifierReceipts.entries()) {
|
|
594
|
+
const next = current.verifierReceipts[index];
|
|
595
|
+
if (!same({ ...prior, output: null, receipt: null }, { ...next, output: null, receipt: null }) || prior.receipt !== null && !same(prior, next))
|
|
596
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
597
|
+
}
|
|
598
|
+
if (current.verifierRefusals.length < previous.verifierRefusals.length || !same(current.verifierRefusals.slice(0, previous.verifierRefusals.length), previous.verifierRefusals))
|
|
599
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
600
|
+
for (const row of current.verifierRefusals.slice(previous.verifierRefusals.length)) {
|
|
601
|
+
const ordinal = plan.verifierSlots.findIndex(slot => slot.id === row.slot);
|
|
602
|
+
if (current.stage.kind !== 'verifier_pre' || current.stage.phase !== 'verify.' + row.generation + '.' + ordinal + '.pre' || row.generation !== current.candidate.generation)
|
|
603
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
604
|
+
}
|
|
605
|
+
const rank = { idle: 0, pending: 1, unresolved: 2, confirmed: 3, failed: 3 };
|
|
606
|
+
if (rank[current.publication.status] < rank[previous.publication.status] || previous.publication.operationId !== null && previous.publication.operationId !== current.publication.operationId
|
|
607
|
+
|| previous.publication.receipt !== null && !same(previous.publication.receipt, current.publication.receipt))
|
|
608
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
609
|
+
for (const failure of previous.failures) {
|
|
610
|
+
const retained = current.failures.find(item => same(item.signature, failure.signature));
|
|
611
|
+
if (!retained || retained.count < failure.count || retained.generation !== failure.generation)
|
|
612
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
export class ProgressStore {
|
|
616
|
+
store;
|
|
617
|
+
authority;
|
|
618
|
+
artifacts;
|
|
619
|
+
plan;
|
|
620
|
+
lock;
|
|
621
|
+
planRef;
|
|
622
|
+
sourceRef;
|
|
623
|
+
constructor(store, authority, artifacts, plan, lock, planRef, sourceRef) {
|
|
624
|
+
this.store = store;
|
|
625
|
+
this.authority = authority;
|
|
626
|
+
this.artifacts = artifacts;
|
|
627
|
+
this.plan = plan;
|
|
628
|
+
this.lock = lock;
|
|
629
|
+
this.planRef = planRef;
|
|
630
|
+
this.sourceRef = sourceRef;
|
|
631
|
+
}
|
|
632
|
+
#overlayBounds() { return overlayManifestBounds(this.plan.budgets.overlay); }
|
|
633
|
+
#progressBounds() {
|
|
634
|
+
const hasExtendedMetadata = this.plan.orderedDAG.some(node => node.handoffs !== undefined)
|
|
635
|
+
|| this.plan.task.spec.trustedContext.resources.some(res => res.when !== undefined);
|
|
636
|
+
const wide = this.plan.capacity.D > 64 || hasExtendedMetadata;
|
|
637
|
+
return { maxBytes: wide ? 262_144 : 65_536, collectionLimit: wide ? 1024 : 256 };
|
|
638
|
+
}
|
|
639
|
+
async manifest(ref) {
|
|
640
|
+
const bounds = this.#overlayBounds();
|
|
641
|
+
const identified = identifyManifest(parsePrivateJson(await this.artifacts.read(ref, bounds.manifestMaxBytes), bounds.manifestMaxBytes, bounds.collectionLimit), bounds.options);
|
|
642
|
+
if (!identified.ok)
|
|
643
|
+
refuse('ARTIFACT_INVALID', '', 'recovery');
|
|
644
|
+
const manifest = identified.value.manifest;
|
|
645
|
+
if (manifest.metadata.id !== 'candidate'
|
|
646
|
+
|| !same([...manifest.spec.entries].sort((a, b) => compareUtf16(a.name, b.name)), manifest.spec.entries)
|
|
647
|
+
|| (manifest.spec.deleted !== undefined && !same([...manifest.spec.deleted].sort(compareUtf16), manifest.spec.deleted))) {
|
|
648
|
+
refuse('ARTIFACT_INVALID', '', 'recovery');
|
|
649
|
+
}
|
|
650
|
+
return manifest;
|
|
651
|
+
}
|
|
652
|
+
async read() {
|
|
653
|
+
if (!same(parsePrivateJson(await this.artifacts.read(this.planRef, 4194304), 4194304), this.plan))
|
|
654
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
655
|
+
const bounds = this.#overlayBounds(), pBounds = this.#progressBounds();
|
|
656
|
+
const verified = new Set(), wrappers = new Set(), manifests = new Map(), negativeAnchors = new Set();
|
|
657
|
+
const verify = async (ref, maximum = 67108864) => {
|
|
658
|
+
if (ref.byteLength > maximum)
|
|
659
|
+
refuse('ARTIFACT_INVALID', '', 'recovery');
|
|
660
|
+
const key = canonical(ref);
|
|
661
|
+
if (!verified.has(key)) {
|
|
662
|
+
await this.artifacts.read(ref, maximum);
|
|
663
|
+
verified.add(key);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
const before = journal(this.store), schedule = phaseSchedule(this.plan.capacity), emitted = [];
|
|
667
|
+
let head = null;
|
|
668
|
+
for (const checkpoint of before.checkpoints) {
|
|
669
|
+
const phase = schedule.find(phase => phaseCheckpointId(this.lock.spec.runId, phase) === checkpoint.checkpointId);
|
|
670
|
+
if (!phase || emitted.includes(phase) || !same(checkpoint.clockBasis, before.view.clock.basis))
|
|
671
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
672
|
+
emitted.push(phase);
|
|
673
|
+
if (phase.endsWith('.native')) {
|
|
674
|
+
if (checkpoint.additionalArtifacts.length !== 0 || !emitted.includes(phase.replace('.native', '.pre')))
|
|
675
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
676
|
+
await verify(checkpoint.workspace, Math.max(67_108_864, bounds.workspaceMaxBytes));
|
|
677
|
+
if (checkpoint.privateSession !== null)
|
|
678
|
+
await verify(checkpoint.privateSession, 67108864);
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
if (checkpoint.additionalArtifacts.length !== 4 || !same(checkpoint.additionalArtifacts.slice(2), [this.planRef, this.sourceRef]))
|
|
682
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
683
|
+
const ref = checkpoint.additionalArtifacts[0], progress = validateProgress(parsePrivateJson(await this.artifacts.read(ref, pBounds.maxBytes), pBounds.maxBytes, pBounds.collectionLimit), this.plan, this.lock);
|
|
684
|
+
const manifestKey = canonical(progress.candidate.manifest);
|
|
685
|
+
let manifest = manifests.get(manifestKey);
|
|
686
|
+
if (!manifest) {
|
|
687
|
+
manifest = await this.manifest(progress.candidate.manifest);
|
|
688
|
+
manifests.set(manifestKey, manifest);
|
|
689
|
+
}
|
|
690
|
+
const subject = bindSubject(this.lock, manifest, bounds.options);
|
|
691
|
+
if (!subject.ok || !same(subject.value, checkpoint.subject) || !same(progress.candidate.digest, subject.value.candidateDigest) || progress.sequence !== checkpoint.sequence
|
|
692
|
+
|| !same(progress.stage.consumed, emitted) || !same(progress.stage.watermarks, { requests: checkpoint.counts.requests, operations: checkpoint.counts.operations })
|
|
693
|
+
|| !same(progress.candidate.workspace, checkpoint.workspace) || !same(progress.candidate.privateSession, checkpoint.privateSession) || !same(progress.previous, head?.ref ?? null))
|
|
694
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
695
|
+
extension(head?.progress ?? null, progress, this.plan);
|
|
696
|
+
for (const row of progress.verifierRefusals) {
|
|
697
|
+
const key = row.slot + ':' + row.generation;
|
|
698
|
+
if (negativeAnchors.has(key))
|
|
699
|
+
continue;
|
|
700
|
+
const ordinal = this.plan.verifierSlots.findIndex(slot => slot.id === row.slot);
|
|
701
|
+
if (phase !== 'verify.' + row.generation + '.' + ordinal + '.pre' || !same(row.subject, checkpoint.subject))
|
|
702
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
703
|
+
const source = parsePrivateJson(await this.artifacts.read(this.sourceRef, 262144), 262144), sourceManifestRef = checkedRef(source.manifest), sourceManifest = await this.manifest(sourceManifestRef);
|
|
704
|
+
const value = checkedRefusalRecord(parsePrivateJson(await this.artifacts.read(row.record, 65536), 65536), this.plan, this.lock, row);
|
|
705
|
+
refusalSubject(this.lock, manifest, row, value, sourceManifestRef, progress.candidate.manifest, sourceManifest);
|
|
706
|
+
const absent = this.store.getOperation(row.prospectiveOperationId);
|
|
707
|
+
if (absent.ok || absent.error.code !== 'RECORD_NOT_FOUND')
|
|
708
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
709
|
+
negativeAnchors.add(key);
|
|
710
|
+
}
|
|
711
|
+
const index = await this.index(progress);
|
|
712
|
+
const actualIndex = parsePrivateJson(await this.artifacts.read(checkpoint.additionalArtifacts[1], pBounds.maxBytes), pBounds.maxBytes, pBounds.collectionLimit);
|
|
713
|
+
if (!same(index, actualIndex))
|
|
714
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
715
|
+
await verify(checkpoint.workspace, Math.max(67_108_864, bounds.workspaceMaxBytes));
|
|
716
|
+
if (checkpoint.privateSession)
|
|
717
|
+
await verify(checkpoint.privateSession, 67108864);
|
|
718
|
+
for (const entry of index.entries)
|
|
719
|
+
await verify(entry.ref);
|
|
720
|
+
for (const attempt of progress.attempts) {
|
|
721
|
+
await verify(attempt.command, 1048576);
|
|
722
|
+
for (const ext of (attempt.handoffExtracts ?? [])) {
|
|
723
|
+
if (ext.status === 'extracted' && ext.artifact !== null && ext.extractSha256 !== null) {
|
|
724
|
+
const casKey = 'cas:' + ext.extractSha256 + ':' + ext.byteLength;
|
|
725
|
+
if (!verified.has(casKey)) {
|
|
726
|
+
if (this.artifacts instanceof ArtifactStore) {
|
|
727
|
+
await streamVerifiedCasBlob(this.artifacts.directory, {
|
|
728
|
+
name: ext.artifact.name,
|
|
729
|
+
sha256: ext.extractSha256,
|
|
730
|
+
byteLength: ext.byteLength,
|
|
731
|
+
uri: ext.artifact.uri,
|
|
732
|
+
blobRef: ext.artifact,
|
|
733
|
+
}, undefined, 'recovery');
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
await this.artifacts.read({
|
|
737
|
+
name: 'blobs/sha256/' + ext.extractSha256,
|
|
738
|
+
byteLength: ext.byteLength,
|
|
739
|
+
digest: ext.artifact.digest,
|
|
740
|
+
}, LIMITS.handoffMaxBytes);
|
|
741
|
+
}
|
|
742
|
+
verified.add(casKey);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
if (!attempt.finished)
|
|
747
|
+
continue;
|
|
748
|
+
await verify(attempt.finished.outcome, 4194304);
|
|
749
|
+
const wrapperKey = attempt.id + '\0' + canonical(attempt.finished.outcome);
|
|
750
|
+
if (attempt.finished.nativeCheckpointId === null || wrappers.has(wrapperKey))
|
|
751
|
+
continue;
|
|
752
|
+
const wrapper = record(parsePrivateJson(await this.artifacts.read(attempt.finished.outcome, 4194304), 4194304, 16384), ['version', 'attemptId', 'command', 'roleId', 'nodeId', 'stepId', 'sessionId', 'checkpointId', 'originalManifest', 'manifest', 'workspace', 'session', 'submission', 'journal']);
|
|
753
|
+
const native = before.checkpoints.find(cp => cp.checkpointId === attempt.finished.nativeCheckpointId), node = this.plan.orderedDAG.find(node => node.id === attempt.nodeId);
|
|
754
|
+
if (!native || native.sequence > checkpoint.sequence || !same(attempt.finished.after, { requests: native.counts.requests, operations: native.counts.operations }) || wrapper.version !== 1 || wrapper.attemptId !== attempt.id || wrapper.nodeId !== attempt.nodeId || wrapper.roleId !== node.roleId
|
|
755
|
+
|| wrapper.stepId !== attempt.nativeStepId || wrapper.sessionId !== attempt.sessionId || wrapper.checkpointId !== native.checkpointId || !same(wrapper.command, attempt.command)
|
|
756
|
+
|| !same(wrapper.workspace, native.workspace) || !same(wrapper.session, native.privateSession))
|
|
757
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
758
|
+
const originalRef = checkedRef(wrapper.originalManifest), manifestRef = checkedRef(wrapper.manifest);
|
|
759
|
+
const original = identifyManifest(parsePrivateJson(await this.artifacts.read(originalRef, bounds.manifestMaxBytes), bounds.manifestMaxBytes, bounds.collectionLimit), bounds.options);
|
|
760
|
+
const canonicalManifest = await this.manifest(manifestRef);
|
|
761
|
+
if (!original.ok)
|
|
762
|
+
refuse('ARTIFACT_INVALID', '', 'recovery');
|
|
763
|
+
const originalSubject = bindSubject(this.lock, original.value.manifest, bounds.options);
|
|
764
|
+
if (!originalSubject.ok || !same(originalSubject.value, native.subject) || !same(canonicalManifest, canonicalizeCandidateManifest(original.value.manifest)))
|
|
765
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
766
|
+
if (wrapper.submission !== null)
|
|
767
|
+
await verify(checkedRef(wrapper.submission), 1048576);
|
|
768
|
+
const interval = record(wrapper.journal, ['requestIds', 'operationIds']);
|
|
769
|
+
if (!same(interval.requestIds, before.requests.filter(item => item.sequence > attempt.before.requests && item.sequence <= native.counts.requests).map(item => item.admission.requestId))
|
|
770
|
+
|| !same(interval.operationIds, before.operations.filter(item => item.sequence > attempt.before.operations && item.sequence <= native.counts.operations).map(item => item.intent.operationId)))
|
|
771
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
772
|
+
wrappers.add(wrapperKey);
|
|
773
|
+
}
|
|
774
|
+
if (progress.submission)
|
|
775
|
+
await verify(progress.submission, 1048576);
|
|
776
|
+
if (progress.nodeSubmissions) {
|
|
777
|
+
for (const subRef of Object.values(progress.nodeSubmissions))
|
|
778
|
+
await verify(subRef, 1048576);
|
|
779
|
+
}
|
|
780
|
+
if (progress.nodeCandidates) {
|
|
781
|
+
for (const snap of Object.values(progress.nodeCandidates)) {
|
|
782
|
+
const snapManifestKey = canonical(snap.manifest);
|
|
783
|
+
let snapManifest = manifests.get(snapManifestKey);
|
|
784
|
+
if (!snapManifest) {
|
|
785
|
+
snapManifest = await this.manifest(snap.manifest);
|
|
786
|
+
manifests.set(snapManifestKey, snapManifest);
|
|
787
|
+
}
|
|
788
|
+
const snapSubject = bindSubject(this.lock, snapManifest, bounds.options);
|
|
789
|
+
if (!snapSubject.ok || !same(snapSubject.value.candidateDigest, snap.digest)) {
|
|
790
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
791
|
+
}
|
|
792
|
+
await verify(snap.workspace, Math.max(67_108_864, bounds.workspaceMaxBytes));
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
if (progress.stepVerdicts) {
|
|
796
|
+
for (const verdictItem of progress.stepVerdicts)
|
|
797
|
+
await verify(verdictItem.raw, 1048576);
|
|
798
|
+
}
|
|
799
|
+
head = { checkpoint, ref, progress, index, manifest };
|
|
800
|
+
}
|
|
801
|
+
const after = journal(this.store);
|
|
802
|
+
if (after.view.counts.checkpoints !== before.view.counts.checkpoints || after.view.counts.requests !== before.view.counts.requests || after.view.counts.operations !== before.view.counts.operations)
|
|
803
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
804
|
+
return head;
|
|
805
|
+
}
|
|
806
|
+
async index(progress) {
|
|
807
|
+
const entries = [{ id: 'plan', kind: 'plan', ref: this.planRef }, { id: 'source', kind: 'source', ref: this.sourceRef }];
|
|
808
|
+
for (const attempt of progress.attempts)
|
|
809
|
+
if (attempt.finished)
|
|
810
|
+
entries.push({ id: attempt.id, kind: 'role', ref: attempt.finished.outcome });
|
|
811
|
+
for (const item of progress.verifierReceipts) {
|
|
812
|
+
if (item.output && item.receipt)
|
|
813
|
+
entries.push({ id: item.slot + '.' + item.generation + '.output', kind: 'verifier-output', ref: item.output }, { id: item.slot + '.' + item.generation + '.receipt', kind: 'verifier-receipt', ref: item.receipt });
|
|
814
|
+
}
|
|
815
|
+
for (const row of progress.verifierRefusals)
|
|
816
|
+
entries.push({ id: row.slot + '.' + row.generation + '.refusal', kind: 'preflight-refusal', ref: row.record });
|
|
817
|
+
if (progress.terminalIntent?.result)
|
|
818
|
+
entries.push({ id: 'result', kind: 'result', ref: progress.terminalIntent.result });
|
|
819
|
+
if (progress.terminalIntent?.observations)
|
|
820
|
+
entries.push({ id: 'observations', kind: 'observations', ref: progress.terminalIntent.observations });
|
|
821
|
+
if (progress.publication.receipt !== null)
|
|
822
|
+
entries.push({ id: 'publication.receipt', kind: 'publication-receipt', ref: progress.publication.receipt });
|
|
823
|
+
if (entries.length > 2 * this.plan.capacity.J + this.plan.capacity.A + 4 + (progress.publication.receipt !== null ? 1 : 0) || entries.some(entry => Buffer.byteLength(canonical(entry)) > 768 || Buffer.byteLength(canonical(entry.ref)) > 512))
|
|
824
|
+
refuse('OUTPUT_LIMIT', '', 'execution');
|
|
825
|
+
return { version: 1, runId: this.lock.spec.runId, entries };
|
|
826
|
+
}
|
|
827
|
+
async publish(draft, phase, afterCommit) {
|
|
828
|
+
const artifacts = this.artifacts, authority = this.authority;
|
|
829
|
+
if (!(artifacts instanceof ArtifactStore) || authority === null)
|
|
830
|
+
refuse('AUTHORITY_REFUSED', '', 'execution');
|
|
831
|
+
await artifacts.owner.assertCurrent();
|
|
832
|
+
stateValue(this.store.renew(authority));
|
|
833
|
+
const bounds = this.#overlayBounds(), pBounds = this.#progressBounds();
|
|
834
|
+
const known = await this.read(), records = journal(this.store), schedule = phaseSchedule(this.plan.capacity), checkpointId = phaseCheckpointId(this.lock.spec.runId, phase);
|
|
835
|
+
if (!schedule.includes(phase) || phase.endsWith('.native'))
|
|
836
|
+
refuse('RECOVERY_REQUIRED', '', 'execution');
|
|
837
|
+
const existing = records.checkpoints.find(item => item.checkpointId === checkpointId);
|
|
838
|
+
if (existing) {
|
|
839
|
+
if (!known || known.checkpoint.checkpointId !== checkpointId || !same(known.progress, { ...draft, sequence: known.progress.sequence, previous: known.progress.previous,
|
|
840
|
+
stage: { ...draft.stage, phase, consumed: known.progress.stage.consumed, watermarks: known.progress.stage.watermarks } }))
|
|
841
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
842
|
+
return known;
|
|
843
|
+
}
|
|
844
|
+
const consumed = records.checkpoints.map(cp => schedule.find(item => phaseCheckpointId(this.lock.spec.runId, item) === cp.checkpointId));
|
|
845
|
+
const progress = freeze({ ...draft, sequence: records.view.counts.checkpoints + 1, previous: known?.ref ?? null,
|
|
846
|
+
stage: { ...draft.stage, phase, consumed: [...consumed, phase], watermarks: { requests: records.view.counts.requests, operations: records.view.counts.operations } } });
|
|
847
|
+
validateProgress(progress, this.plan, this.lock);
|
|
848
|
+
extension(known?.progress ?? null, progress, this.plan);
|
|
849
|
+
const manifest = await this.manifest(progress.candidate.manifest), index = await this.index(progress), ref = await artifacts.json('progress', progress, pBounds.maxBytes), indexRef = await artifacts.json('index', index, pBounds.maxBytes);
|
|
850
|
+
const input = { checkpointId, candidateManifest: manifest, workspace: progress.candidate.workspace, privateSession: progress.candidate.privateSession, additionalArtifacts: [ref, indexRef, this.planRef, this.sourceRef] };
|
|
851
|
+
if (Buffer.byteLength(canonical(input)) + 1024 > bounds.checkpointInputMaxBytes)
|
|
852
|
+
refuse('OUTPUT_LIMIT', '', 'execution');
|
|
853
|
+
const current = stateValue(this.store.inspect());
|
|
854
|
+
if (current.counts.checkpoints !== records.view.counts.checkpoints || current.counts.requests !== records.view.counts.requests || current.counts.operations !== records.view.counts.operations)
|
|
855
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
856
|
+
const committed = stateValue(this.store.writeCheckpoint(authority, { ...input, expectedRevision: current.revision })).record;
|
|
857
|
+
afterCommit?.(committed);
|
|
858
|
+
return { checkpoint: committed, ref, progress, index, manifest };
|
|
859
|
+
}
|
|
860
|
+
decision(head) {
|
|
861
|
+
const records = journal(this.store), view = records.view;
|
|
862
|
+
const externalUncertain = records.operations.filter(item => item.intent.effect === 'external_write' && (item.state === 'dispatch_uncertain' || item.state === 'unresolved'));
|
|
863
|
+
if (view.clockStatus !== 'trusted' || view.counts.dispatchedRequests || view.counts.unresolvedRequests || view.counts.unresolvedOperations > externalUncertain.length || view.ledger.violations.length)
|
|
864
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
865
|
+
if (!head) {
|
|
866
|
+
if (view.counts.requests || view.counts.operations || view.counts.checkpoints)
|
|
867
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
868
|
+
return 'not_started';
|
|
869
|
+
}
|
|
870
|
+
if (head.progress.stage.kind.startsWith('terminal') || head.progress.stage.kind === 'reconcile_result') {
|
|
871
|
+
if (view.counts.requests !== head.progress.stage.watermarks.requests || view.counts.operations !== head.progress.stage.watermarks.operations)
|
|
872
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
873
|
+
return 'terminal';
|
|
874
|
+
}
|
|
875
|
+
if (externalUncertain.length)
|
|
876
|
+
return 'reconcile_required';
|
|
877
|
+
const active = head.progress.attempts.at(-1);
|
|
878
|
+
if (active && active.finished === null) {
|
|
879
|
+
const nativeId = phaseCheckpointId(this.lock.spec.runId, 'role.' + active.ordinal + '.native');
|
|
880
|
+
const captured = records.checkpoints.find(cp => cp.checkpointId === nativeId);
|
|
881
|
+
if (captured)
|
|
882
|
+
return 'adopt_capture';
|
|
883
|
+
if (view.counts.requests !== active.before.requests || view.counts.operations !== active.before.operations)
|
|
884
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
885
|
+
return 'safe';
|
|
886
|
+
}
|
|
887
|
+
if (head.progress.stage.kind === 'verifier_pre') {
|
|
888
|
+
const row = head.progress.verifierReceipts.find(item => item.generation === head.progress.candidate.generation && item.receipt === null);
|
|
889
|
+
const additions = records.operations.filter(item => item.sequence > head.progress.stage.watermarks.operations);
|
|
890
|
+
if (row && view.counts.requests === head.progress.stage.watermarks.requests && additions.length <= 1
|
|
891
|
+
&& additions.every(item => item.intent.operationId === row.operationId && item.state === 'confirmed' && item.intent.effect === 'read_only'))
|
|
892
|
+
return 'safe';
|
|
893
|
+
}
|
|
894
|
+
if (head.progress.stage.kind === 'publication_pre' && head.progress.publication.operationId !== null) {
|
|
895
|
+
const additions = records.operations.filter(item => item.sequence > head.progress.stage.watermarks.operations);
|
|
896
|
+
if (view.counts.requests === head.progress.stage.watermarks.requests && additions.length <= 1
|
|
897
|
+
&& additions.every(item => item.intent.operationId === head.progress.publication.operationId && item.state === 'confirmed' && item.intent.effect === 'external_write'))
|
|
898
|
+
return 'safe';
|
|
899
|
+
}
|
|
900
|
+
if (view.counts.requests !== head.progress.stage.watermarks.requests || view.counts.operations !== head.progress.stage.watermarks.operations)
|
|
901
|
+
refuse('RECOVERY_REQUIRED', '', 'recovery');
|
|
902
|
+
return 'safe';
|
|
903
|
+
}
|
|
904
|
+
}
|