devcontour-harness 0.0.0-stage → 0.1.0-alpha.12
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 +21 -0
- package/README.md +268 -2
- package/docs/architecture.md +496 -0
- package/docs/compatibility-versions.md +60 -0
- package/docs/compatibility.md +192 -0
- package/docs/connectors.md +323 -0
- package/docs/contracts.md +630 -0
- package/docs/integrations/hindsight.md +148 -0
- package/docs/quickstart.md +185 -0
- package/docs/release-notes/0.1.0-alpha.10.md +50 -0
- package/docs/release-notes/0.1.0-alpha.11.md +44 -0
- package/docs/release-notes/0.1.0-alpha.12.md +66 -0
- package/docs/release-notes/0.1.0-alpha.6.md +238 -0
- package/docs/release-notes/0.1.0-alpha.7.md +71 -0
- package/docs/release-notes/0.1.0-alpha.8.md +73 -0
- package/docs/release-notes/0.1.0-alpha.9.md +55 -0
- package/docs/review-probes.md +199 -0
- package/docs/review-protocol.md +251 -0
- package/docs/standalone.md +271 -0
- package/docs/toolchains.md +167 -0
- package/docs/turbo-starter.md +269 -0
- package/docs/upgrade.md +219 -0
- package/examples/README.md +27 -0
- package/examples/external-connector/README.md +19 -0
- package/examples/external-connector/connector.mjs +55 -0
- package/examples/files-only/README.md +28 -0
- package/examples/files-only/context/norms/rules.md +4 -0
- package/examples/files-only/graph.json +23 -0
- package/examples/files-only/policy.json +30 -0
- package/examples/one-vendor/README.md +19 -0
- package/examples/one-vendor/policy.json +27 -0
- package/examples/single-task/README.md +18 -0
- package/examples/single-task/graph.json +27 -0
- package/examples/single-task/policy-same-vendor.json +55 -0
- package/examples/single-task/policy.json +52 -0
- package/examples/single-task/src/.gitkeep +0 -0
- package/examples/single-task/test/run.js +19 -0
- package/examples/toolchains/README.md +32 -0
- package/examples/toolchains/go/bad/label/label.go +9 -0
- package/examples/toolchains/go/good/label/label.go +9 -0
- package/examples/toolchains/go/policy.json +79 -0
- package/examples/toolchains/go/repo/REQUIREMENTS.md +9 -0
- package/examples/toolchains/go/repo/_gitignore +1 -0
- package/examples/toolchains/go/repo/go.mod +5 -0
- package/examples/toolchains/go/repo/go.sum +2 -0
- package/examples/toolchains/go/repo/label/label.go +9 -0
- package/examples/toolchains/go/repo/label/label_test.go +27 -0
- package/examples/toolchains/go/repo/label/version.go +9 -0
- package/examples/toolchains/go/task.json +25 -0
- package/examples/toolchains/mixed-go/bad/backend/label/label.go +9 -0
- package/examples/toolchains/mixed-go/bad/frontend/src/label.js +4 -0
- package/examples/toolchains/mixed-go/good/backend/label/label.go +9 -0
- package/examples/toolchains/mixed-go/good/frontend/src/label.js +4 -0
- package/examples/toolchains/mixed-go/policy.json +126 -0
- package/examples/toolchains/mixed-go/repo/REQUIREMENTS.md +9 -0
- package/examples/toolchains/mixed-go/repo/_gitignore +6 -0
- package/examples/toolchains/mixed-go/repo/backend/go.mod +3 -0
- package/examples/toolchains/mixed-go/repo/backend/label/label.go +9 -0
- package/examples/toolchains/mixed-go/repo/backend/label/label_test.go +30 -0
- package/examples/toolchains/mixed-go/repo/contract/check.mjs +17 -0
- package/examples/toolchains/mixed-go/repo/contract/label.json +9 -0
- package/examples/toolchains/mixed-go/repo/frontend/package.json +15 -0
- package/examples/toolchains/mixed-go/repo/frontend/pnpm-lock.yaml +22 -0
- package/examples/toolchains/mixed-go/repo/frontend/src/label.js +4 -0
- package/examples/toolchains/mixed-go/repo/frontend/test/label.test.js +11 -0
- package/examples/toolchains/mixed-go/task.json +25 -0
- package/examples/toolchains/mixed-python/bad/backend/src/fx_backend/__init__.py +6 -0
- package/examples/toolchains/mixed-python/bad/frontend/src/label.js +4 -0
- package/examples/toolchains/mixed-python/good/backend/src/fx_backend/__init__.py +6 -0
- package/examples/toolchains/mixed-python/good/frontend/src/label.js +4 -0
- package/examples/toolchains/mixed-python/policy.json +121 -0
- package/examples/toolchains/mixed-python/repo/REQUIREMENTS.md +9 -0
- package/examples/toolchains/mixed-python/repo/_gitignore +6 -0
- package/examples/toolchains/mixed-python/repo/backend/.python-version +1 -0
- package/examples/toolchains/mixed-python/repo/backend/pyproject.toml +19 -0
- package/examples/toolchains/mixed-python/repo/backend/src/fx_backend/__init__.py +6 -0
- package/examples/toolchains/mixed-python/repo/backend/tests/test_label.py +11 -0
- package/examples/toolchains/mixed-python/repo/backend/uv.lock +108 -0
- package/examples/toolchains/mixed-python/repo/contract/check.mjs +17 -0
- package/examples/toolchains/mixed-python/repo/contract/label.json +9 -0
- package/examples/toolchains/mixed-python/repo/frontend/package.json +15 -0
- package/examples/toolchains/mixed-python/repo/frontend/pnpm-lock.yaml +22 -0
- package/examples/toolchains/mixed-python/repo/frontend/src/label.js +4 -0
- package/examples/toolchains/mixed-python/repo/frontend/test/label.test.js +11 -0
- package/examples/toolchains/mixed-python/task.json +25 -0
- package/examples/toolchains/npm/bad/src/label.js +4 -0
- package/examples/toolchains/npm/good/src/label.js +4 -0
- package/examples/toolchains/npm/policy.json +82 -0
- package/examples/toolchains/npm/repo/REQUIREMENTS.md +9 -0
- package/examples/toolchains/npm/repo/_gitignore +4 -0
- package/examples/toolchains/npm/repo/package-lock.json +22 -0
- package/examples/toolchains/npm/repo/package.json +13 -0
- package/examples/toolchains/npm/repo/src/label.js +4 -0
- package/examples/toolchains/npm/repo/test/label.test.js +13 -0
- package/examples/toolchains/npm/task.json +25 -0
- package/examples/toolchains/pnpm/bad/packages/label/src/label.js +4 -0
- package/examples/toolchains/pnpm/good/packages/label/src/label.js +4 -0
- package/examples/toolchains/pnpm/policy.json +85 -0
- package/examples/toolchains/pnpm/repo/REQUIREMENTS.md +9 -0
- package/examples/toolchains/pnpm/repo/_gitignore +4 -0
- package/examples/toolchains/pnpm/repo/package.json +10 -0
- package/examples/toolchains/pnpm/repo/packages/checker/check.mjs +5 -0
- package/examples/toolchains/pnpm/repo/packages/checker/package.json +9 -0
- package/examples/toolchains/pnpm/repo/packages/label/package.json +14 -0
- package/examples/toolchains/pnpm/repo/packages/label/src/label.js +4 -0
- package/examples/toolchains/pnpm/repo/packages/label/test/label.test.js +13 -0
- package/examples/toolchains/pnpm/repo/pnpm-lock.yaml +29 -0
- package/examples/toolchains/pnpm/repo/pnpm-workspace.yaml +2 -0
- package/examples/toolchains/pnpm/task.json +25 -0
- package/examples/toolchains/python/bad/src/fx_label/__init__.py +6 -0
- package/examples/toolchains/python/good/src/fx_label/__init__.py +6 -0
- package/examples/toolchains/python/policy.json +80 -0
- package/examples/toolchains/python/repo/.python-version +1 -0
- package/examples/toolchains/python/repo/REQUIREMENTS.md +9 -0
- package/examples/toolchains/python/repo/_gitignore +5 -0
- package/examples/toolchains/python/repo/pyproject.toml +19 -0
- package/examples/toolchains/python/repo/src/fx_label/__init__.py +6 -0
- package/examples/toolchains/python/repo/tests/test_label.py +13 -0
- package/examples/toolchains/python/repo/uv.lock +108 -0
- package/examples/toolchains/python/task.json +25 -0
- package/examples/toolchains/turbo/bad/packages/label/src/label.js +4 -0
- package/examples/toolchains/turbo/good/packages/label/src/label.js +4 -0
- package/examples/toolchains/turbo/policy.json +110 -0
- package/examples/toolchains/turbo/repo/REQUIREMENTS.md +9 -0
- package/examples/toolchains/turbo/repo/_gitignore +4 -0
- package/examples/toolchains/turbo/repo/package.json +13 -0
- package/examples/toolchains/turbo/repo/packages/checker/check.mjs +5 -0
- package/examples/toolchains/turbo/repo/packages/checker/package.json +9 -0
- package/examples/toolchains/turbo/repo/packages/label/package.json +14 -0
- package/examples/toolchains/turbo/repo/packages/label/src/label.js +4 -0
- package/examples/toolchains/turbo/repo/packages/label/test/label.test.js +13 -0
- package/examples/toolchains/turbo/repo/pnpm-lock.yaml +94 -0
- package/examples/toolchains/turbo/repo/pnpm-workspace.yaml +2 -0
- package/examples/toolchains/turbo/repo/turbo.json +7 -0
- package/examples/toolchains/turbo/task.json +25 -0
- package/examples/turbo-starter/README.md +16 -0
- package/examples/turbo-starter/changes/issued-at-consumer-only.patch +12 -0
- package/examples/turbo-starter/changes/issued-at.patch +130 -0
- package/examples/turbo-starter/cleanup.mjs +58 -0
- package/examples/turbo-starter/graph.json +32 -0
- package/examples/turbo-starter/harness/acceptance/db-isolation.test.mjs +97 -0
- package/examples/turbo-starter/harness/acceptance/env-probe.test.mjs +75 -0
- package/examples/turbo-starter/harness/acceptance/generation.test.mjs +54 -0
- package/examples/turbo-starter/harness/acceptance/issued-at.test.mjs +43 -0
- package/examples/turbo-starter/harness/acceptance/lifecycle-probe.test.mjs +47 -0
- package/examples/turbo-starter/harness/compose-bridge.mjs +593 -0
- package/examples/turbo-starter/harness/compose.acceptance.yml +23 -0
- package/examples/turbo-starter/harness/env/backend.env.template +7 -0
- package/examples/turbo-starter/harness/env/compose.env.template +6 -0
- package/examples/turbo-starter/policy.json +109 -0
- package/examples/turbo-starter/policy.lifecycle.json +114 -0
- package/examples/turbo-starter/setup.mjs +352 -0
- package/examples/two-vendors/policy.json +30 -0
- package/lib/agents/cli-adapter.d.ts +48 -0
- package/lib/agents/cli-adapter.js +393 -0
- package/lib/agents/inspect.d.ts +60 -0
- package/lib/agents/inspect.js +296 -0
- package/lib/agents/probe-server.d.ts +2 -0
- package/lib/agents/probe-server.js +13 -0
- package/lib/agents/review-probe.d.ts +345 -0
- package/lib/agents/review-probe.js +1037 -0
- package/lib/agents/runtime-events.d.ts +11 -0
- package/lib/agents/runtime-events.js +21 -0
- package/lib/agents/schemas.d.ts +217 -0
- package/lib/agents/schemas.js +124 -0
- package/lib/agents/usage.d.ts +8 -0
- package/lib/agents/usage.js +83 -0
- package/lib/catalog/bytes.d.ts +9 -0
- package/lib/catalog/bytes.js +14 -0
- package/lib/catalog/harness.d.ts +3 -0
- package/lib/catalog/harness.js +11 -0
- package/lib/catalog/index.d.ts +5 -0
- package/lib/catalog/index.js +5 -0
- package/lib/catalog/operations.d.ts +24 -0
- package/lib/catalog/operations.js +74 -0
- package/lib/catalog/page.d.ts +46 -0
- package/lib/catalog/page.js +128 -0
- package/lib/catalog/shared.d.ts +37 -0
- package/lib/catalog/shared.js +67 -0
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +673 -0
- package/lib/connectors/files.d.ts +108 -0
- package/lib/connectors/files.js +133 -0
- package/lib/contracts/catalog.d.ts +31 -0
- package/lib/contracts/catalog.js +18 -0
- package/lib/contracts/checks.d.ts +307 -0
- package/lib/contracts/checks.js +181 -0
- package/lib/contracts/cli.d.ts +4665 -0
- package/lib/contracts/cli.js +840 -0
- package/lib/contracts/context.d.ts +135 -0
- package/lib/contracts/context.js +129 -0
- package/lib/contracts/diagnosis.d.ts +108 -0
- package/lib/contracts/diagnosis.js +69 -0
- package/lib/contracts/digest.d.ts +9 -0
- package/lib/contracts/digest.js +22 -0
- package/lib/contracts/errors.d.ts +89 -0
- package/lib/contracts/errors.js +74 -0
- package/lib/contracts/events.d.ts +827 -0
- package/lib/contracts/events.js +258 -0
- package/lib/contracts/execution.d.ts +3423 -0
- package/lib/contracts/execution.js +936 -0
- package/lib/contracts/failure.d.ts +38 -0
- package/lib/contracts/failure.js +53 -0
- package/lib/contracts/index.d.ts +22 -0
- package/lib/contracts/index.js +22 -0
- package/lib/contracts/planning.d.ts +433 -0
- package/lib/contracts/planning.js +159 -0
- package/lib/contracts/policy.d.ts +1075 -0
- package/lib/contracts/policy.js +544 -0
- package/lib/contracts/ports.d.ts +417 -0
- package/lib/contracts/ports.js +1 -0
- package/lib/contracts/primitives.d.ts +63 -0
- package/lib/contracts/primitives.js +73 -0
- package/lib/contracts/profiles.d.ts +340 -0
- package/lib/contracts/profiles.js +109 -0
- package/lib/contracts/project.d.ts +69 -0
- package/lib/contracts/project.js +47 -0
- package/lib/contracts/published.d.ts +3467 -0
- package/lib/contracts/published.js +40 -0
- package/lib/contracts/repair-policy.d.ts +31 -0
- package/lib/contracts/repair-policy.js +77 -0
- package/lib/contracts/result.d.ts +1284 -0
- package/lib/contracts/result.js +311 -0
- package/lib/contracts/review.d.ts +441 -0
- package/lib/contracts/review.js +477 -0
- package/lib/contracts/toolchain.d.ts +96 -0
- package/lib/contracts/toolchain.js +89 -0
- package/lib/contracts/version.d.ts +17 -0
- package/lib/contracts/version.js +17 -0
- package/lib/contracts/work.d.ts +171 -0
- package/lib/contracts/work.js +178 -0
- package/lib/control/base-move.d.ts +44 -0
- package/lib/control/base-move.js +90 -0
- package/lib/control/doctor.d.ts +50 -0
- package/lib/control/doctor.js +113 -0
- package/lib/control/harness.d.ts +1125 -0
- package/lib/control/harness.js +741 -0
- package/lib/control/provenance.d.ts +17 -0
- package/lib/control/provenance.js +25 -0
- package/lib/control/recovery.d.ts +237 -0
- package/lib/control/recovery.js +236 -0
- package/lib/control/review.d.ts +62 -0
- package/lib/control/review.js +182 -0
- package/lib/control/workflow.d.ts +256 -0
- package/lib/control/workflow.js +277 -0
- package/lib/engine/budget.d.ts +345 -0
- package/lib/engine/budget.js +278 -0
- package/lib/engine/classify.d.ts +8 -0
- package/lib/engine/classify.js +41 -0
- package/lib/engine/engine.d.ts +1564 -0
- package/lib/engine/engine.js +2283 -0
- package/lib/engine/failure.d.ts +1 -0
- package/lib/engine/failure.js +3 -0
- package/lib/engine/joint-runner.d.ts +257 -0
- package/lib/engine/joint-runner.js +254 -0
- package/lib/engine/measured.d.ts +15 -0
- package/lib/engine/measured.js +82 -0
- package/lib/engine/prompt.d.ts +66 -0
- package/lib/engine/prompt.js +131 -0
- package/lib/engine/property-recovery.d.ts +50 -0
- package/lib/engine/property-recovery.js +171 -0
- package/lib/engine/repair.d.ts +33 -0
- package/lib/engine/repair.js +82 -0
- package/lib/engine/result.d.ts +9 -0
- package/lib/engine/result.js +194 -0
- package/lib/engine/reuse.d.ts +80 -0
- package/lib/engine/reuse.js +102 -0
- package/lib/engine/runner.d.ts +360 -0
- package/lib/engine/runner.js +1844 -0
- package/lib/engine/standalone.d.ts +6 -0
- package/lib/engine/standalone.js +48 -0
- package/lib/engine/usage.d.ts +87 -0
- package/lib/engine/usage.js +165 -0
- package/lib/environment/isolation.d.ts +110 -0
- package/lib/environment/isolation.js +238 -0
- package/lib/environment/lifecycle.d.ts +40 -0
- package/lib/environment/lifecycle.js +197 -0
- package/lib/environment/live-calls.d.ts +14 -0
- package/lib/environment/live-calls.js +73 -0
- package/lib/environment/os-tools.d.ts +16 -0
- package/lib/environment/os-tools.js +35 -0
- package/lib/environment/process.d.ts +40 -0
- package/lib/environment/process.js +375 -0
- package/lib/environment/redaction.d.ts +22 -0
- package/lib/environment/redaction.js +102 -0
- package/lib/environment/resources.d.ts +31 -0
- package/lib/environment/resources.js +120 -0
- package/lib/explain/diagnose.d.ts +25 -0
- package/lib/explain/diagnose.js +60 -0
- package/lib/explain/state.d.ts +18 -0
- package/lib/explain/state.js +305 -0
- package/lib/index.d.ts +72 -0
- package/lib/index.js +74 -0
- package/lib/init/policy.d.ts +40 -0
- package/lib/init/policy.js +73 -0
- package/lib/init/project.d.ts +52 -0
- package/lib/init/project.js +412 -0
- package/lib/integrations/connector/commands.d.ts +358 -0
- package/lib/integrations/connector/commands.js +428 -0
- package/lib/integrations/connector/config.d.ts +215 -0
- package/lib/integrations/connector/config.js +214 -0
- package/lib/integrations/connector/delivery.d.ts +107 -0
- package/lib/integrations/connector/delivery.js +591 -0
- package/lib/integrations/connector/fake.d.ts +291 -0
- package/lib/integrations/connector/fake.js +786 -0
- package/lib/integrations/connector/history.d.ts +124 -0
- package/lib/integrations/connector/history.js +497 -0
- package/lib/integrations/connector/index.d.ts +16 -0
- package/lib/integrations/connector/index.js +16 -0
- package/lib/integrations/connector/redact.d.ts +19 -0
- package/lib/integrations/connector/redact.js +91 -0
- package/lib/integrations/connector/registry.d.ts +15 -0
- package/lib/integrations/connector/registry.js +43 -0
- package/lib/integrations/connector/snapshot.d.ts +131 -0
- package/lib/integrations/connector/snapshot.js +422 -0
- package/lib/integrations/connector/source.d.ts +37 -0
- package/lib/integrations/connector/source.js +73 -0
- package/lib/integrations/connector/steps.d.ts +71 -0
- package/lib/integrations/connector/steps.js +188 -0
- package/lib/integrations/connector/store.d.ts +140 -0
- package/lib/integrations/connector/store.js +277 -0
- package/lib/integrations/connector/summary.d.ts +38 -0
- package/lib/integrations/connector/summary.js +59 -0
- package/lib/integrations/connector/testing-worker.d.ts +1 -0
- package/lib/integrations/connector/testing-worker.js +81 -0
- package/lib/integrations/connector/testing.d.ts +205 -0
- package/lib/integrations/connector/testing.js +1615 -0
- package/lib/integrations/connector/transport.d.ts +240 -0
- package/lib/integrations/connector/transport.js +28 -0
- package/lib/integrations/memory/context.d.ts +120 -0
- package/lib/integrations/memory/context.js +239 -0
- package/lib/integrations/memory/index.d.ts +8 -0
- package/lib/integrations/memory/index.js +8 -0
- package/lib/integrations/memory/provider.d.ts +79 -0
- package/lib/integrations/memory/provider.js +22 -0
- package/lib/integrations/memory/sink.d.ts +56 -0
- package/lib/integrations/memory/sink.js +116 -0
- package/lib/integrations/memory/testing.d.ts +44 -0
- package/lib/integrations/memory/testing.js +61 -0
- package/lib/integrations/relay-v1/index.d.ts +122 -0
- package/lib/integrations/relay-v1/index.js +860 -0
- package/lib/integrations/relay-v2/index.d.ts +145 -0
- package/lib/integrations/relay-v2/index.js +752 -0
- package/lib/integrations/relay-v2/process.d.ts +32 -0
- package/lib/integrations/relay-v2/process.js +112 -0
- package/lib/integrations/relay-v2/protocol.d.ts +172 -0
- package/lib/integrations/relay-v2/protocol.js +142 -0
- package/lib/package.d.ts +2 -0
- package/lib/package.js +3 -0
- package/lib/planning/check.d.ts +26 -0
- package/lib/planning/check.js +174 -0
- package/lib/planning/facts.d.ts +13 -0
- package/lib/planning/facts.js +47 -0
- package/lib/planning/graph.d.ts +20 -0
- package/lib/planning/graph.js +114 -0
- package/lib/planning/index.d.ts +6 -0
- package/lib/planning/index.js +6 -0
- package/lib/planning/issues.d.ts +19 -0
- package/lib/planning/issues.js +210 -0
- package/lib/planning/request.d.ts +19 -0
- package/lib/planning/request.js +57 -0
- package/lib/planning/standalone.d.ts +16 -0
- package/lib/planning/standalone.js +19 -0
- package/lib/planning/stub.d.ts +2 -0
- package/lib/planning/stub.js +5 -0
- package/lib/profiles/resolve.d.ts +266 -0
- package/lib/profiles/resolve.js +322 -0
- package/lib/projections/chain.d.ts +35 -0
- package/lib/projections/chain.js +72 -0
- package/lib/projections/clip.d.ts +6 -0
- package/lib/projections/clip.js +23 -0
- package/lib/projections/enums.d.ts +7 -0
- package/lib/projections/enums.js +19 -0
- package/lib/projections/index.d.ts +8 -0
- package/lib/projections/index.js +9 -0
- package/lib/projections/next.d.ts +28 -0
- package/lib/projections/next.js +75 -0
- package/lib/projections/progress.d.ts +27 -0
- package/lib/projections/progress.js +37 -0
- package/lib/projections/queue.d.ts +21 -0
- package/lib/projections/queue.js +18 -0
- package/lib/projections/stop.d.ts +98 -0
- package/lib/projections/stop.js +532 -0
- package/lib/setup/files.d.ts +45 -0
- package/lib/setup/files.js +280 -0
- package/lib/storage/document.d.ts +1286 -0
- package/lib/storage/document.js +80 -0
- package/lib/storage/sqlite.d.ts +35 -0
- package/lib/storage/sqlite.js +260 -0
- package/lib/testing/index.d.ts +5 -0
- package/lib/testing/index.js +5 -0
- package/lib/testing/store-contract.d.ts +8 -0
- package/lib/testing/store-contract.js +167 -0
- package/lib/toolchains/index.d.ts +9 -0
- package/lib/toolchains/index.js +9 -0
- package/lib/toolchains/inspect.d.ts +105 -0
- package/lib/toolchains/inspect.js +831 -0
- package/lib/toolchains/manifests.d.ts +67 -0
- package/lib/toolchains/manifests.js +238 -0
- package/lib/toolchains/probe.d.ts +28 -0
- package/lib/toolchains/probe.js +54 -0
- package/lib/toolchains/recipes.d.ts +33 -0
- package/lib/toolchains/recipes.js +51 -0
- package/lib/validate.d.ts +37 -0
- package/lib/validate.js +182 -0
- package/lib/verification/acceptance.d.ts +284 -0
- package/lib/verification/acceptance.js +670 -0
- package/lib/verification/checks.d.ts +72 -0
- package/lib/verification/checks.js +190 -0
- package/lib/verification/confirm.d.ts +125 -0
- package/lib/verification/confirm.js +411 -0
- package/lib/verification/corpus.d.ts +1303 -0
- package/lib/verification/corpus.js +744 -0
- package/lib/verification/dependencies.d.ts +66 -0
- package/lib/verification/dependencies.js +144 -0
- package/lib/verification/gates.d.ts +182 -0
- package/lib/verification/gates.js +641 -0
- package/lib/verification/joint.d.ts +63 -0
- package/lib/verification/joint.js +121 -0
- package/lib/verification/proof.d.ts +54 -0
- package/lib/verification/proof.js +96 -0
- package/lib/verification/property.d.ts +86 -0
- package/lib/verification/property.js +214 -0
- package/lib/verification/requirements.d.ts +25 -0
- package/lib/verification/requirements.js +69 -0
- package/lib/verification/self-check.d.ts +29 -0
- package/lib/verification/self-check.js +99 -0
- package/lib/verification/spike.d.ts +79 -0
- package/lib/verification/spike.js +124 -0
- package/package.json +104 -4
- package/profiles/expo-mobile.json +15 -0
- package/profiles/go-api.json +15 -0
- package/profiles/go-gotestsum.json +21 -0
- package/profiles/mobile-maestro.json +29 -0
- package/profiles/nest-api.json +26 -0
- package/profiles/next-product.json +72 -0
- package/profiles/node-checks.json +77 -0
- package/profiles/npm-ci.json +22 -0
- package/profiles/pnpm-frozen.json +24 -0
- package/profiles/python-api.json +32 -0
- package/profiles/python-uv.json +26 -0
- package/profiles/react-native.json +50 -0
- package/profiles/react-vite-admin.json +71 -0
- package/schemas/context-snapshot.schema.json +231 -0
- package/schemas/contract-document.schema.json +385 -0
- package/schemas/execution-document.schema.json +3881 -0
- package/schemas/execution-policy.schema.json +2196 -0
- package/schemas/joint-verification.schema.json +617 -0
- package/schemas/plan-draft.schema.json +217 -0
- package/schemas/project-manifest.schema.json +167 -0
- package/schemas/result-envelope.schema.json +1654 -0
- package/schemas/review-record.schema.json +177 -0
- package/schemas/run-event.schema.json +2458 -0
- package/schemas/run-result.schema.json +1572 -0
- package/schemas/stack-profile.schema.json +535 -0
- package/schemas/stop-diagnosis.schema.json +169 -0
- package/schemas/work-graph.schema.json +381 -0
- package/schemas/work-order.schema.json +256 -0
- package/skills/harness/SKILL.md +247 -0
- package/skills/harness-setup/SKILL.md +356 -0
- package/templates/AGENTS.md +13 -0
- package/templates/controller-mode/AGENTS.controller.md +58 -0
- package/templates/controller-mode/README.md +44 -0
- package/templates/graph.json +22 -0
- package/templates/plan-draft.json +35 -0
- package/templates/policy.json +28 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { HarnessError, } from "../../contracts/index.js";
|
|
4
|
+
import { redactor } from "../../environment/redaction.js";
|
|
5
|
+
import { connectorIdOf, loadConfig, orderIdOf, resolveFrom, storeFileOf, } from "./config.js";
|
|
6
|
+
import { RelaySink } from "./delivery.js";
|
|
7
|
+
import { HistoryRecorder } from "./history.js";
|
|
8
|
+
import { createTransportFor } from "./registry.js";
|
|
9
|
+
import { assertEligible, checkIdentity, matchCriterion, readStable, semanticDigest, } from "./snapshot.js";
|
|
10
|
+
import { RelayWorkSource } from "./source.js";
|
|
11
|
+
import { redactingTransport, settingsSecrets } from "./redact.js";
|
|
12
|
+
import { ConnectorStore } from "./store.js";
|
|
13
|
+
/**
|
|
14
|
+
* Пользовательский путь коннектора — общий для CLI и библиотеки:
|
|
15
|
+
* `check` → `snapshot` → (review-plan/approve) → `run` → `status` →
|
|
16
|
+
* `deliver`/`reconcile`. Ни одна операция не требует писать TypeScript.
|
|
17
|
+
*/
|
|
18
|
+
export const OWNERSHIP_NOTE = 'Один владелец доставки гарантирован только для процессов с общим каталогом состояния коннектора (lease с fencing в его SQLite). Независимые установки с разными каталогами состояния вне гарантии: они могут доставить одну операцию дважды.';
|
|
19
|
+
export async function openConnector(source, options) {
|
|
20
|
+
const loaded = typeof source === 'string' ? loadConfig(source) : source;
|
|
21
|
+
const transport = options.transport ?? (await createTransportFor(loaded));
|
|
22
|
+
return new Connector(loaded, transport, options);
|
|
23
|
+
}
|
|
24
|
+
export class Connector {
|
|
25
|
+
loaded;
|
|
26
|
+
options;
|
|
27
|
+
id;
|
|
28
|
+
stateDir;
|
|
29
|
+
storeFile;
|
|
30
|
+
storeInstance;
|
|
31
|
+
redact;
|
|
32
|
+
/** Транспорт с замаскированными ошибками (известные секреты не выходят в диагностику). */
|
|
33
|
+
transport;
|
|
34
|
+
constructor(loaded, transport, options) {
|
|
35
|
+
this.loaded = loaded;
|
|
36
|
+
this.options = options;
|
|
37
|
+
const config = loaded.config;
|
|
38
|
+
this.id = connectorIdOf(config.provider, config.projectId);
|
|
39
|
+
this.stateDir = config.stateDir
|
|
40
|
+
? resolveFrom(loaded.baseDir, config.stateDir)
|
|
41
|
+
: resolve(options.stateDir);
|
|
42
|
+
this.storeFile = storeFileOf(this.stateDir, config.provider, config.projectId);
|
|
43
|
+
this.redact = redactor([...(options.secrets ?? []), ...settingsSecrets(config.relay)]);
|
|
44
|
+
this.transport = redactingTransport(transport, this.redact);
|
|
45
|
+
}
|
|
46
|
+
get config() {
|
|
47
|
+
return this.loaded.config;
|
|
48
|
+
}
|
|
49
|
+
/** Состояние коннектора (создаётся при первой записи). */
|
|
50
|
+
get store() {
|
|
51
|
+
this.storeInstance ??= new ConnectorStore(this.storeFile, { provider: this.config.provider, projectId: this.config.projectId }, this.options.onStoreWrite ? { onWrite: this.options.onStoreWrite } : {});
|
|
52
|
+
return this.storeInstance;
|
|
53
|
+
}
|
|
54
|
+
/** Только чтение: без создания файла; нет состояния — `undefined`. */
|
|
55
|
+
readStore() {
|
|
56
|
+
if (this.storeInstance)
|
|
57
|
+
return this.storeInstance;
|
|
58
|
+
if (!existsSync(this.storeFile))
|
|
59
|
+
return undefined;
|
|
60
|
+
return new ConnectorStore(this.storeFile, { provider: this.config.provider, projectId: this.config.projectId }, { readOnly: true });
|
|
61
|
+
}
|
|
62
|
+
get source() {
|
|
63
|
+
return new RelayWorkSource({
|
|
64
|
+
config: this.config,
|
|
65
|
+
transport: this.transport,
|
|
66
|
+
store: this.store,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
get history() {
|
|
70
|
+
return new HistoryRecorder({
|
|
71
|
+
config: this.config,
|
|
72
|
+
transport: this.transport,
|
|
73
|
+
store: this.store,
|
|
74
|
+
connectorId: this.id,
|
|
75
|
+
redact: this.redact,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
get sink() {
|
|
79
|
+
return new RelaySink({
|
|
80
|
+
config: this.config,
|
|
81
|
+
transport: this.transport,
|
|
82
|
+
store: this.store,
|
|
83
|
+
connectorId: this.id,
|
|
84
|
+
history: this.history,
|
|
85
|
+
redact: this.redact,
|
|
86
|
+
...(this.options.owner ? { owner: this.options.owner } : {}),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** Хуки runner для `HarnessOptions.hooks`: история до исполнения попытки. */
|
|
90
|
+
hooks() {
|
|
91
|
+
return this.history.hooks();
|
|
92
|
+
}
|
|
93
|
+
close() {
|
|
94
|
+
this.storeInstance?.close();
|
|
95
|
+
this.storeInstance = undefined;
|
|
96
|
+
}
|
|
97
|
+
/* ---------------------------------------------------------------- */
|
|
98
|
+
/* source-check */
|
|
99
|
+
/* ---------------------------------------------------------------- */
|
|
100
|
+
/**
|
|
101
|
+
* Подключение, идентичность, capabilities, совпадение проекта и mapping —
|
|
102
|
+
* только чтением: без мутаций backend, без записи истории и без создания
|
|
103
|
+
* состояния коннектора.
|
|
104
|
+
*/
|
|
105
|
+
async check(policy) {
|
|
106
|
+
const config = this.config;
|
|
107
|
+
const problems = [];
|
|
108
|
+
let identity;
|
|
109
|
+
try {
|
|
110
|
+
identity = await checkIdentity(this.transport, config);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
const message = this.redact(error instanceof Error ? error.message : String(error));
|
|
114
|
+
return this.checkReport(undefined, false, [message], []);
|
|
115
|
+
}
|
|
116
|
+
const mapping = [];
|
|
117
|
+
try {
|
|
118
|
+
const { reads } = await readStable(this.transport, config.tasks.map((t) => t.ref), config.limits.rereads);
|
|
119
|
+
reads.forEach((read, i) => {
|
|
120
|
+
const m = config.tasks[i];
|
|
121
|
+
const issues = [];
|
|
122
|
+
m.criteria.forEach((c, k) => {
|
|
123
|
+
const n = matchCriterion(read.task.criteria, c).length;
|
|
124
|
+
if (n !== 1)
|
|
125
|
+
issues.push(`criteria[${k}] (${c.id ?? c.title}): совпадений ${n}`);
|
|
126
|
+
});
|
|
127
|
+
for (const d of m.requiredDocuments)
|
|
128
|
+
if (read.documents.filter((x) => x.id === d || x.key === d || x.name === d).length !== 1)
|
|
129
|
+
issues.push(`requiredDocuments: ${d} не найден однозначно`);
|
|
130
|
+
const unmapped = read.task.criteria.filter((c) => !m.criteria.some((x) => matchCriterion([c], x).length === 1));
|
|
131
|
+
if (unmapped.length)
|
|
132
|
+
issues.push('ручные критерии (без mapping, блокируют done): ' +
|
|
133
|
+
unmapped.map((c) => c.title).join(', '));
|
|
134
|
+
if (policy) {
|
|
135
|
+
const repoId = m.repositoryId ?? config.repository.id;
|
|
136
|
+
const repo = policy.repositories.find((r) => r.id === repoId);
|
|
137
|
+
if (!repo)
|
|
138
|
+
issues.push(`репозиторий ${repoId} не объявлен в политике`);
|
|
139
|
+
else
|
|
140
|
+
for (const c of m.criteria)
|
|
141
|
+
if (!repo.gates.some((g) => g.id === c.gate))
|
|
142
|
+
issues.push(`gate ${c.gate} критерия ${c.id ?? c.title} не объявлен в политике`);
|
|
143
|
+
if (!policy.roles[m.role])
|
|
144
|
+
issues.push(`роль ${m.role} не объявлена в политике`);
|
|
145
|
+
}
|
|
146
|
+
mapping.push({ ref: m.ref, key: read.task.key, problems: issues });
|
|
147
|
+
problems.push(...issues.filter((x) => !x.startsWith('ручные')).map((x) => `${read.task.key}: ${x}`));
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
problems.push(this.redact(error instanceof Error ? error.message : String(error)));
|
|
152
|
+
}
|
|
153
|
+
return this.checkReport(identity, true, problems, mapping);
|
|
154
|
+
}
|
|
155
|
+
checkReport(identity, projectMatches, problems, mapping) {
|
|
156
|
+
const caps = identity?.capabilities ?? [];
|
|
157
|
+
return {
|
|
158
|
+
provider: this.config.provider,
|
|
159
|
+
projectId: this.config.projectId,
|
|
160
|
+
connector: this.id,
|
|
161
|
+
connected: Boolean(identity),
|
|
162
|
+
projectMatches: Boolean(identity) && projectMatches,
|
|
163
|
+
...(identity ? { identity: { capabilities: caps, build: identity.build } } : {}),
|
|
164
|
+
history: {
|
|
165
|
+
enabled: this.config.history.enabled,
|
|
166
|
+
capability: caps.some((c) => /history/.test(c)),
|
|
167
|
+
},
|
|
168
|
+
mapping,
|
|
169
|
+
ownership: { stateDir: this.stateDir, store: this.storeFile, note: OWNERSHIP_NOTE },
|
|
170
|
+
problems,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/* ---------------------------------------------------------------- */
|
|
174
|
+
/* source-snapshot */
|
|
175
|
+
/* ---------------------------------------------------------------- */
|
|
176
|
+
/**
|
|
177
|
+
* Прочитать и предпросмотреть снимок; записать graph/context/manifest для
|
|
178
|
+
* `review-plan`/`approve`. Снимок закрепляется в состоянии коннектора по
|
|
179
|
+
* semantic digest: повтор неизменной постановки ничего не меняет.
|
|
180
|
+
*/
|
|
181
|
+
async snapshot(outDir) {
|
|
182
|
+
const snapshot = await this.source.snapshot();
|
|
183
|
+
const { created } = this.store.putSnapshot({
|
|
184
|
+
revision: snapshot.revision,
|
|
185
|
+
graphId: snapshot.graph.id,
|
|
186
|
+
graph: snapshot.graph,
|
|
187
|
+
context: snapshot.context,
|
|
188
|
+
manifest: snapshot.manifest,
|
|
189
|
+
});
|
|
190
|
+
const dir = resolve(outDir ?? join(this.stateDir, 'connectors', 'snapshots', snapshot.graph.id));
|
|
191
|
+
mkdirSync(dir, { recursive: true });
|
|
192
|
+
const files = {
|
|
193
|
+
graph: join(dir, 'graph.json'),
|
|
194
|
+
context: join(dir, 'context.json'),
|
|
195
|
+
manifest: join(dir, 'manifest.json'),
|
|
196
|
+
};
|
|
197
|
+
writeFileSync(files.graph, JSON.stringify(snapshot.graph, null, 2) + '\n');
|
|
198
|
+
writeFileSync(files.context, JSON.stringify(snapshot.context, null, 2) + '\n');
|
|
199
|
+
writeFileSync(files.manifest, JSON.stringify(snapshot.manifest, null, 2) + '\n');
|
|
200
|
+
return {
|
|
201
|
+
connector: this.id,
|
|
202
|
+
graphId: snapshot.graph.id,
|
|
203
|
+
graphDigest: snapshot.manifest.graphDigest,
|
|
204
|
+
contextDigest: snapshot.manifest.contextDigest,
|
|
205
|
+
revision: snapshot.revision,
|
|
206
|
+
created,
|
|
207
|
+
eligible: snapshot.problems.length === 0,
|
|
208
|
+
problems: snapshot.problems.map((p) => `${p.key}: ${p.code}: ${p.message}`),
|
|
209
|
+
truncated: snapshot.manifest.truncated,
|
|
210
|
+
tasks: snapshot.manifest.tasks.map((t) => ({
|
|
211
|
+
identity: t.identity,
|
|
212
|
+
key: t.key,
|
|
213
|
+
orderId: t.orderId,
|
|
214
|
+
semanticDigest: t.semanticDigest,
|
|
215
|
+
casRevision: t.casRevision,
|
|
216
|
+
column: t.column,
|
|
217
|
+
})),
|
|
218
|
+
files,
|
|
219
|
+
snapshot,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/* ---------------------------------------------------------------- */
|
|
223
|
+
/* run --source */
|
|
224
|
+
/* ---------------------------------------------------------------- */
|
|
225
|
+
/**
|
|
226
|
+
* Перед запуском — свежее чтение: semantic digest обязан совпасть с
|
|
227
|
+
* закреплённым снимком (тем, что прошёл ревью/согласование), eligibility —
|
|
228
|
+
* выполняться. Иначе отказ до любого вызова runtime. Исполняется ровно
|
|
229
|
+
* закреплённый граф и контекст (те же байты, что видел reviewer плана).
|
|
230
|
+
*/
|
|
231
|
+
async prepareRun(h) {
|
|
232
|
+
const fresh = await this.source.snapshot();
|
|
233
|
+
const stored = this.store.latestSnapshot(fresh.graph.id);
|
|
234
|
+
if (!stored)
|
|
235
|
+
throw new HarnessError('APPROVAL_REQUIRED', 'Снимок задач не закреплён: выполните source-snapshot, review-plan и approve');
|
|
236
|
+
if (stored.revision !== fresh.revision)
|
|
237
|
+
throw new HarnessError('APPROVAL_STALE', `Постановка изменилась после закреплённого снимка (${stored.revision.slice(0, 12)} → ${fresh.revision.slice(0, 12)}): нужен новый source-snapshot, review-plan и approve`);
|
|
238
|
+
const registered = h.engine.read((v) => v.graph(fresh.graph.id));
|
|
239
|
+
if (registered?.approval &&
|
|
240
|
+
registered.graph.source.revision !== fresh.revision &&
|
|
241
|
+
h.policy.approvalMode === 'operator')
|
|
242
|
+
throw new HarnessError('APPROVAL_STALE', 'Согласован другой снимок задач; повторите review-plan и approve для текущего');
|
|
243
|
+
// Колонка, в которую задачу перевела наша же подтверждённая доставка этой
|
|
244
|
+
// постановки, — не новая постановка и не повод отказать повтору (он
|
|
245
|
+
// продолжит прежнюю работу без нового run и записей).
|
|
246
|
+
const own = (p) => {
|
|
247
|
+
if (p.code !== 'TASK_DONE' && p.code !== 'COLUMN_NOT_ELIGIBLE')
|
|
248
|
+
return false;
|
|
249
|
+
const digest = fresh.manifest.tasks.find((t) => t.id === p.taskId)?.semanticDigest;
|
|
250
|
+
return this.store
|
|
251
|
+
.operations({ taskId: p.taskId })
|
|
252
|
+
.some((o) => o.status === 'delivered' && o.revision === digest);
|
|
253
|
+
};
|
|
254
|
+
assertEligible({ ...fresh, problems: fresh.problems.filter((p) => !own(p)) });
|
|
255
|
+
return { graph: stored.graph, context: stored.context };
|
|
256
|
+
}
|
|
257
|
+
async run(h, options = {}) {
|
|
258
|
+
const { graph, context } = await this.prepareRun(h);
|
|
259
|
+
return h.run({
|
|
260
|
+
graph,
|
|
261
|
+
context,
|
|
262
|
+
author: options.author ?? 'external',
|
|
263
|
+
source: this.source,
|
|
264
|
+
sink: this.sink,
|
|
265
|
+
...(options.once ? { once: true } : {}),
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/* ---------------------------------------------------------------- */
|
|
269
|
+
/* source-status / deliver / reconcile */
|
|
270
|
+
/* ---------------------------------------------------------------- */
|
|
271
|
+
workIds() {
|
|
272
|
+
return this.config.tasks.map((t) => t.ref);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Локальное состояние (принято, доставлено, конфликт, неизвестный исход) и
|
|
276
|
+
* независимое чтение получателя. Ошибка чтения получателя показывается, а не
|
|
277
|
+
* заменяется пустым состоянием.
|
|
278
|
+
*/
|
|
279
|
+
async status(h) {
|
|
280
|
+
const store = this.readStore();
|
|
281
|
+
try {
|
|
282
|
+
const snapshot = store?.latestSnapshotAny();
|
|
283
|
+
const manifest = snapshot?.manifest;
|
|
284
|
+
const tasks = [];
|
|
285
|
+
for (const [index, mapping] of this.config.tasks.entries()) {
|
|
286
|
+
const fromManifest = manifest?.tasks.find((t) => t.ref === mapping.ref);
|
|
287
|
+
const taskId = fromManifest?.id ?? mapping.ref;
|
|
288
|
+
const workId = orderIdOf(this.config.provider, this.config.projectId, taskId);
|
|
289
|
+
const work = h?.engine.read((v) => v.work(workId));
|
|
290
|
+
let deliveries = [];
|
|
291
|
+
if (h && work)
|
|
292
|
+
try {
|
|
293
|
+
deliveries = h.result(workId).delivery.map((d) => ({
|
|
294
|
+
status: d.status,
|
|
295
|
+
key: d.key,
|
|
296
|
+
...(d.operation ? { operation: d.operation } : {}),
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
deliveries = [];
|
|
301
|
+
}
|
|
302
|
+
const operations = (store?.operations({ workId }) ?? []).map((o) => ({
|
|
303
|
+
key: o.key,
|
|
304
|
+
runId: o.runId,
|
|
305
|
+
outcome: o.outcome,
|
|
306
|
+
status: o.status,
|
|
307
|
+
...(o.reason ? { reason: o.reason } : {}),
|
|
308
|
+
...(o.currentRevision ? { currentRevision: o.currentRevision } : {}),
|
|
309
|
+
steps: o.steps.map((s) => ({ n: s.n, kind: s.kind, status: s.status, marker: s.marker })),
|
|
310
|
+
lease: ((l) => l && l.expiresAt > Date.now()
|
|
311
|
+
? { owner: l.owner, expiresAt: new Date(l.expiresAt).toISOString() }
|
|
312
|
+
: undefined)(store?.lease(o.key)),
|
|
313
|
+
}));
|
|
314
|
+
let remote;
|
|
315
|
+
try {
|
|
316
|
+
const read = await this.transport.readTask(taskId);
|
|
317
|
+
const comments = await this.transport.listComments(taskId);
|
|
318
|
+
remote = {
|
|
319
|
+
reachable: true,
|
|
320
|
+
column: read.task.column,
|
|
321
|
+
casRevision: read.task.revision,
|
|
322
|
+
semanticDigest: semanticDigest(this.config, mapping, read),
|
|
323
|
+
matchesSnapshot: fromManifest
|
|
324
|
+
? semanticDigest(this.config, mapping, read) === fromManifest.semanticDigest
|
|
325
|
+
: false,
|
|
326
|
+
criteria: read.task.criteria.map((c) => ({
|
|
327
|
+
id: c.id,
|
|
328
|
+
title: c.title,
|
|
329
|
+
completed: c.completed,
|
|
330
|
+
})),
|
|
331
|
+
markers: Object.fromEntries(operations.map((o) => [
|
|
332
|
+
o.key,
|
|
333
|
+
comments.filter((c) => c.body.includes(`op=${o.key}:`)).length,
|
|
334
|
+
])),
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
remote = {
|
|
339
|
+
reachable: false,
|
|
340
|
+
error: this.redact(error instanceof Error ? error.message : String(error)),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
tasks.push({
|
|
344
|
+
index,
|
|
345
|
+
ref: mapping.ref,
|
|
346
|
+
...(fromManifest ? { key: fromManifest.key, identity: fromManifest.identity } : {}),
|
|
347
|
+
workId,
|
|
348
|
+
local: work
|
|
349
|
+
? {
|
|
350
|
+
status: work.status,
|
|
351
|
+
attempt: work.attempt,
|
|
352
|
+
...(work.resultSha ? { resultSha: work.resultSha } : {}),
|
|
353
|
+
}
|
|
354
|
+
: { status: 'unknown' },
|
|
355
|
+
deliveries,
|
|
356
|
+
operations,
|
|
357
|
+
remote,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
connector: this.id,
|
|
362
|
+
provider: this.config.provider,
|
|
363
|
+
projectId: this.config.projectId,
|
|
364
|
+
...(manifest
|
|
365
|
+
? { snapshot: { revision: manifest.revision, graphId: manifest.graphId } }
|
|
366
|
+
: {}),
|
|
367
|
+
ownership: { stateDir: this.stateDir, store: this.storeFile, note: OWNERSHIP_NOTE },
|
|
368
|
+
tasks,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
finally {
|
|
372
|
+
if (store && store !== this.storeInstance)
|
|
373
|
+
store.close();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/** Доставить результаты (повтор — с тем же ключом, без writer/reviewer и Git). */
|
|
377
|
+
async deliver(h, workId) {
|
|
378
|
+
const ids = workId
|
|
379
|
+
? [workId]
|
|
380
|
+
: this.config.tasks
|
|
381
|
+
.map((t) => {
|
|
382
|
+
const snapshot = this.store.latestSnapshotAny();
|
|
383
|
+
const manifest = snapshot?.manifest;
|
|
384
|
+
const id = manifest?.tasks.find((x) => x.ref === t.ref)?.id ?? t.ref;
|
|
385
|
+
return orderIdOf(this.config.provider, this.config.projectId, id);
|
|
386
|
+
})
|
|
387
|
+
.filter((id) => h.engine.read((v) => v.attempts(id).some((a) => a.status !== 'active')));
|
|
388
|
+
const sink = this.sink;
|
|
389
|
+
const out = [];
|
|
390
|
+
for (const id of ids) {
|
|
391
|
+
const envelope = await h.deliver(id, sink);
|
|
392
|
+
out.push({ workId: id, delivery: envelope.delivery, outcome: envelope.result.outcome });
|
|
393
|
+
}
|
|
394
|
+
return { connector: this.id, deliveries: out };
|
|
395
|
+
}
|
|
396
|
+
/** Разбор неизвестного исхода/конфликта и, если факты позволяют, продолжение доставки. */
|
|
397
|
+
async reconcile(h, operation, decision) {
|
|
398
|
+
const op = this.store.operation(operation);
|
|
399
|
+
if (!op)
|
|
400
|
+
throw new HarnessError('NOT_FOUND', 'Операция доставки не найдена: ' + operation);
|
|
401
|
+
const report = await this.sink.reconcile(operation, decision);
|
|
402
|
+
let delivery;
|
|
403
|
+
if (report.resolved) {
|
|
404
|
+
const envelope = await h.deliver(op.workId, this.sink);
|
|
405
|
+
delivery = envelope.delivery;
|
|
406
|
+
}
|
|
407
|
+
const after = this.store.operation(operation);
|
|
408
|
+
return {
|
|
409
|
+
operation,
|
|
410
|
+
workId: op.workId,
|
|
411
|
+
before: report.before,
|
|
412
|
+
after: after.status,
|
|
413
|
+
resolved: report.resolved,
|
|
414
|
+
facts: report.facts,
|
|
415
|
+
...(delivery ? { delivery } : {}),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
/** Расшифровка решения CLI `--decision resend|recheck|adopt:<id>`. */
|
|
419
|
+
static decision(text) {
|
|
420
|
+
if (!text)
|
|
421
|
+
return undefined;
|
|
422
|
+
if (text === 'resend' || text === 'recheck')
|
|
423
|
+
return { kind: text };
|
|
424
|
+
if (text.startsWith('adopt:') && text.length > 6)
|
|
425
|
+
return { kind: 'adopt', id: text.slice(6) };
|
|
426
|
+
throw new HarnessError('INVALID_INPUT', '--decision: ожидается resend, recheck или adopt:<id>');
|
|
427
|
+
}
|
|
428
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ProviderId, TaskColumn } from './transport.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Конфигурация коннектора внешнего хранилища задач.
|
|
5
|
+
*
|
|
6
|
+
* Provider выбирается явно (`relay-v1-http` | `relay-v2-cli`) и никогда не
|
|
7
|
+
* угадывается по имени binary. `projectId` — ожидаемая идентичность проекта:
|
|
8
|
+
* несовпадение с тем, что сообщил backend, блокирует любые мутации. Настройки
|
|
9
|
+
* provider (`relay`) проверяет адаптер; ядро требует только минимально нужные
|
|
10
|
+
* поля, чтобы ошибка была видна до подключения.
|
|
11
|
+
*/
|
|
12
|
+
export declare const providerIds: ["relay-v1-http", "relay-v2-cli"];
|
|
13
|
+
export declare const taskColumns: ["inbox", "ready", "in-progress", "review", "done", "cancelled"];
|
|
14
|
+
/** Сопоставление критерия задачи с доказательством принятого результата. */
|
|
15
|
+
export declare const criterionMappingSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodOptional<z.ZodString>;
|
|
17
|
+
title: z.ZodOptional<z.ZodString>;
|
|
18
|
+
gate: z.ZodString;
|
|
19
|
+
testId: z.ZodOptional<z.ZodString>;
|
|
20
|
+
evidence: z.ZodDefault<z.ZodEnum<{
|
|
21
|
+
gate: "gate";
|
|
22
|
+
test: "test";
|
|
23
|
+
}>>;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export type CriterionMapping = z.infer<typeof criterionMappingSchema>;
|
|
26
|
+
export declare const taskMappingSchema: z.ZodObject<{
|
|
27
|
+
ref: z.ZodString;
|
|
28
|
+
role: z.ZodDefault<z.ZodString>;
|
|
29
|
+
repositoryId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
writeScope: z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<".">, z.ZodString]>>;
|
|
31
|
+
gates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
criteria: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
33
|
+
id: z.ZodOptional<z.ZodString>;
|
|
34
|
+
title: z.ZodOptional<z.ZodString>;
|
|
35
|
+
gate: z.ZodString;
|
|
36
|
+
testId: z.ZodOptional<z.ZodString>;
|
|
37
|
+
evidence: z.ZodDefault<z.ZodEnum<{
|
|
38
|
+
gate: "gate";
|
|
39
|
+
test: "test";
|
|
40
|
+
}>>;
|
|
41
|
+
}, z.core.$strict>>>;
|
|
42
|
+
requiredDocuments: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
export type TaskMapping = z.infer<typeof taskMappingSchema>;
|
|
45
|
+
export declare const connectorConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
46
|
+
provider: z.ZodLiteral<"relay-v1-http">;
|
|
47
|
+
relay: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodObject<{
|
|
48
|
+
endpoint: z.ZodString;
|
|
49
|
+
}, z.core.$loose>>;
|
|
50
|
+
version: z.ZodLiteral<1>;
|
|
51
|
+
projectId: z.ZodString;
|
|
52
|
+
actor: z.ZodString;
|
|
53
|
+
stateDir: z.ZodOptional<z.ZodString>;
|
|
54
|
+
repository: z.ZodObject<{
|
|
55
|
+
id: z.ZodString;
|
|
56
|
+
path: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
59
|
+
ref: z.ZodString;
|
|
60
|
+
role: z.ZodDefault<z.ZodString>;
|
|
61
|
+
repositoryId: z.ZodOptional<z.ZodString>;
|
|
62
|
+
writeScope: z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<".">, z.ZodString]>>;
|
|
63
|
+
gates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
criteria: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
65
|
+
id: z.ZodOptional<z.ZodString>;
|
|
66
|
+
title: z.ZodOptional<z.ZodString>;
|
|
67
|
+
gate: z.ZodString;
|
|
68
|
+
testId: z.ZodOptional<z.ZodString>;
|
|
69
|
+
evidence: z.ZodDefault<z.ZodEnum<{
|
|
70
|
+
gate: "gate";
|
|
71
|
+
test: "test";
|
|
72
|
+
}>>;
|
|
73
|
+
}, z.core.$strict>>>;
|
|
74
|
+
requiredDocuments: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
75
|
+
}, z.core.$strict>>;
|
|
76
|
+
completion: z.ZodDefault<z.ZodObject<{
|
|
77
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
78
|
+
complete: "complete";
|
|
79
|
+
"review-only": "review-only";
|
|
80
|
+
}>>;
|
|
81
|
+
column: z.ZodOptional<z.ZodEnum<{
|
|
82
|
+
ready: "ready";
|
|
83
|
+
review: "review";
|
|
84
|
+
cancelled: "cancelled";
|
|
85
|
+
done: "done";
|
|
86
|
+
"in-progress": "in-progress";
|
|
87
|
+
inbox: "inbox";
|
|
88
|
+
}>>;
|
|
89
|
+
historicalComment: z.ZodDefault<z.ZodBoolean>;
|
|
90
|
+
}, z.core.$strict>>;
|
|
91
|
+
eligibility: z.ZodDefault<z.ZodObject<{
|
|
92
|
+
columns: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
93
|
+
ready: "ready";
|
|
94
|
+
review: "review";
|
|
95
|
+
cancelled: "cancelled";
|
|
96
|
+
done: "done";
|
|
97
|
+
"in-progress": "in-progress";
|
|
98
|
+
inbox: "inbox";
|
|
99
|
+
}>>>;
|
|
100
|
+
}, z.core.$strict>>;
|
|
101
|
+
limits: z.ZodDefault<z.ZodObject<{
|
|
102
|
+
documents: z.ZodDefault<z.ZodNumber>;
|
|
103
|
+
documentBytes: z.ZodDefault<z.ZodNumber>;
|
|
104
|
+
totalBytes: z.ZodDefault<z.ZodNumber>;
|
|
105
|
+
taskBytes: z.ZodDefault<z.ZodNumber>;
|
|
106
|
+
rereads: z.ZodDefault<z.ZodNumber>;
|
|
107
|
+
leaseMs: z.ZodDefault<z.ZodNumber>;
|
|
108
|
+
}, z.core.$strict>>;
|
|
109
|
+
history: z.ZodDefault<z.ZodObject<{
|
|
110
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
111
|
+
client: z.ZodDefault<z.ZodString>;
|
|
112
|
+
}, z.core.$strict>>;
|
|
113
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
114
|
+
provider: z.ZodLiteral<"relay-v2-cli">;
|
|
115
|
+
relay: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodObject<{
|
|
116
|
+
binary: z.ZodString;
|
|
117
|
+
config: z.ZodString;
|
|
118
|
+
project: z.ZodOptional<z.ZodString>;
|
|
119
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
120
|
+
}, z.core.$loose>>;
|
|
121
|
+
version: z.ZodLiteral<1>;
|
|
122
|
+
projectId: z.ZodString;
|
|
123
|
+
actor: z.ZodString;
|
|
124
|
+
stateDir: z.ZodOptional<z.ZodString>;
|
|
125
|
+
repository: z.ZodObject<{
|
|
126
|
+
id: z.ZodString;
|
|
127
|
+
path: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, z.core.$strict>;
|
|
129
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
130
|
+
ref: z.ZodString;
|
|
131
|
+
role: z.ZodDefault<z.ZodString>;
|
|
132
|
+
repositoryId: z.ZodOptional<z.ZodString>;
|
|
133
|
+
writeScope: z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<".">, z.ZodString]>>;
|
|
134
|
+
gates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
135
|
+
criteria: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
136
|
+
id: z.ZodOptional<z.ZodString>;
|
|
137
|
+
title: z.ZodOptional<z.ZodString>;
|
|
138
|
+
gate: z.ZodString;
|
|
139
|
+
testId: z.ZodOptional<z.ZodString>;
|
|
140
|
+
evidence: z.ZodDefault<z.ZodEnum<{
|
|
141
|
+
gate: "gate";
|
|
142
|
+
test: "test";
|
|
143
|
+
}>>;
|
|
144
|
+
}, z.core.$strict>>>;
|
|
145
|
+
requiredDocuments: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
146
|
+
}, z.core.$strict>>;
|
|
147
|
+
completion: z.ZodDefault<z.ZodObject<{
|
|
148
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
149
|
+
complete: "complete";
|
|
150
|
+
"review-only": "review-only";
|
|
151
|
+
}>>;
|
|
152
|
+
column: z.ZodOptional<z.ZodEnum<{
|
|
153
|
+
ready: "ready";
|
|
154
|
+
review: "review";
|
|
155
|
+
cancelled: "cancelled";
|
|
156
|
+
done: "done";
|
|
157
|
+
"in-progress": "in-progress";
|
|
158
|
+
inbox: "inbox";
|
|
159
|
+
}>>;
|
|
160
|
+
historicalComment: z.ZodDefault<z.ZodBoolean>;
|
|
161
|
+
}, z.core.$strict>>;
|
|
162
|
+
eligibility: z.ZodDefault<z.ZodObject<{
|
|
163
|
+
columns: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
164
|
+
ready: "ready";
|
|
165
|
+
review: "review";
|
|
166
|
+
cancelled: "cancelled";
|
|
167
|
+
done: "done";
|
|
168
|
+
"in-progress": "in-progress";
|
|
169
|
+
inbox: "inbox";
|
|
170
|
+
}>>>;
|
|
171
|
+
}, z.core.$strict>>;
|
|
172
|
+
limits: z.ZodDefault<z.ZodObject<{
|
|
173
|
+
documents: z.ZodDefault<z.ZodNumber>;
|
|
174
|
+
documentBytes: z.ZodDefault<z.ZodNumber>;
|
|
175
|
+
totalBytes: z.ZodDefault<z.ZodNumber>;
|
|
176
|
+
taskBytes: z.ZodDefault<z.ZodNumber>;
|
|
177
|
+
rereads: z.ZodDefault<z.ZodNumber>;
|
|
178
|
+
leaseMs: z.ZodDefault<z.ZodNumber>;
|
|
179
|
+
}, z.core.$strict>>;
|
|
180
|
+
history: z.ZodDefault<z.ZodObject<{
|
|
181
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
182
|
+
client: z.ZodDefault<z.ZodString>;
|
|
183
|
+
}, z.core.$strict>>;
|
|
184
|
+
}, z.core.$strict>], "provider">;
|
|
185
|
+
export type ConnectorConfig = z.infer<typeof connectorConfigSchema>;
|
|
186
|
+
export type ConnectorConfigInput = z.input<typeof connectorConfigSchema>;
|
|
187
|
+
/** Загруженная конфигурация и каталог, от которого разрешаются её относительные пути. */
|
|
188
|
+
export interface LoadedConfig {
|
|
189
|
+
config: ConnectorConfig;
|
|
190
|
+
baseDir: string;
|
|
191
|
+
file?: string;
|
|
192
|
+
}
|
|
193
|
+
export declare function parseConfig(value: unknown, baseDir: string, file?: string): LoadedConfig;
|
|
194
|
+
export declare function loadConfig(path: string): LoadedConfig;
|
|
195
|
+
export declare const resolveFrom: (baseDir: string, path: string) => string;
|
|
196
|
+
/** ID коннектора (WorkSource/ResultSink и доверенный издатель receipts): provider + проект. */
|
|
197
|
+
export declare const connectorIdOf: (provider: ProviderId, projectId: string) => string;
|
|
198
|
+
/** Стабильная идентичность задачи: backend, проект и постоянный ID задачи. */
|
|
199
|
+
export declare const taskIdentity: (provider: ProviderId, projectId: string, taskId: string) => string;
|
|
200
|
+
export declare function parseIdentity(identity: string): {
|
|
201
|
+
provider: ProviderId;
|
|
202
|
+
projectId: string;
|
|
203
|
+
taskId: string;
|
|
204
|
+
} | undefined;
|
|
205
|
+
/** ID поручения по идентичности задачи: одинаковые номера разных проектов/backend не совпадают. */
|
|
206
|
+
export declare const orderIdOf: (provider: ProviderId, projectId: string, taskId: string) => string;
|
|
207
|
+
export declare const contextIdOf: (orderId: string) => string;
|
|
208
|
+
/** ID графа по набору задач конфигурации. */
|
|
209
|
+
export declare const graphIdOf: (provider: ProviderId, projectId: string, taskIds: string[]) => string;
|
|
210
|
+
/** Digest сопоставления задачи: входит в semantic digest — смена mapping требует нового согласования. */
|
|
211
|
+
export declare const mappingDigest: (config: ConnectorConfig, mapping: TaskMapping) => string;
|
|
212
|
+
/** Колонка завершения по правилам конфигурации. */
|
|
213
|
+
export declare const completionColumn: (config: ConnectorConfig) => TaskColumn;
|
|
214
|
+
/** Файл хранилища коннектора внутри каталога состояния. */
|
|
215
|
+
export declare const storeFileOf: (stateDir: string, provider: ProviderId, projectId: string) => string;
|