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,532 @@
|
|
|
1
|
+
import { errorCodes } from "../contracts/errors.js";
|
|
2
|
+
import { repairPolicy } from "../contracts/repair-policy.js";
|
|
3
|
+
import { CLIP_DIAGNOSTIC, clipText } from "./clip.js";
|
|
4
|
+
/**
|
|
5
|
+
* Код остановки по классу отказа. Это та же таблица, которой RunResult
|
|
6
|
+
* называет stopReason: сетевой класс приходит из сохранённого failureKind
|
|
7
|
+
* (его ставит classifyFailure в точке отказа), текст здесь не разбирается.
|
|
8
|
+
*/
|
|
9
|
+
export function stopCodeOf(kind) {
|
|
10
|
+
switch (kind) {
|
|
11
|
+
case 'gate':
|
|
12
|
+
case 'empty-result':
|
|
13
|
+
return 'GATE_FAILED';
|
|
14
|
+
case 'review':
|
|
15
|
+
return 'REVIEW_REJECTED';
|
|
16
|
+
case 'review-protocol':
|
|
17
|
+
return 'REVIEW_PROTOCOL_INVALID';
|
|
18
|
+
case 'scope-violation':
|
|
19
|
+
return 'SCOPE_VIOLATION';
|
|
20
|
+
case 'budget':
|
|
21
|
+
return 'BUDGET_EXHAUSTED';
|
|
22
|
+
case 'cancelled':
|
|
23
|
+
return 'CANCELLED';
|
|
24
|
+
case 'provider-auth':
|
|
25
|
+
case 'environment':
|
|
26
|
+
case 'timeout':
|
|
27
|
+
return 'RUNTIME_UNAVAILABLE';
|
|
28
|
+
case 'stale-base':
|
|
29
|
+
case 'merge':
|
|
30
|
+
return 'GIT_FAILED';
|
|
31
|
+
default:
|
|
32
|
+
return 'INTERNAL';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const stopCauses = [
|
|
36
|
+
'provider-auth',
|
|
37
|
+
'environment',
|
|
38
|
+
'timeout',
|
|
39
|
+
'stale-base',
|
|
40
|
+
'empty-result',
|
|
41
|
+
'scope-violation',
|
|
42
|
+
'gate',
|
|
43
|
+
'review',
|
|
44
|
+
'review-protocol',
|
|
45
|
+
'merge',
|
|
46
|
+
'cancelled',
|
|
47
|
+
'budget',
|
|
48
|
+
'unknown',
|
|
49
|
+
'runtime-missing',
|
|
50
|
+
'controller-busy',
|
|
51
|
+
'operator-pause',
|
|
52
|
+
'approval-required',
|
|
53
|
+
'not-ready',
|
|
54
|
+
];
|
|
55
|
+
export const stopPhases = [
|
|
56
|
+
'preflight',
|
|
57
|
+
'claim',
|
|
58
|
+
'implementation',
|
|
59
|
+
'gates',
|
|
60
|
+
'review',
|
|
61
|
+
'integration',
|
|
62
|
+
'delivery',
|
|
63
|
+
];
|
|
64
|
+
/** Русский шаблон сообщения по причине остановки. */
|
|
65
|
+
const causeText = {
|
|
66
|
+
'provider-auth': 'Провайдер отказал: runtime не авторизован, нет кредитов или исчерпан лимит.',
|
|
67
|
+
environment: 'Окружение не дало исполнителю работать (сеть, TLS/DNS, процесс runtime).',
|
|
68
|
+
timeout: 'Попытка исчерпала отведённое время.',
|
|
69
|
+
'stale-base': 'База прогонов отстала от рабочей ветки.',
|
|
70
|
+
'empty-result': 'Исполнитель отчитался о выполнении, не изменив ни одного файла.',
|
|
71
|
+
'scope-violation': 'Изменения вышли за область поручения или роли.',
|
|
72
|
+
gate: 'Настроенная проверка не прошла.',
|
|
73
|
+
review: 'Независимое ревью отклонило результат.',
|
|
74
|
+
'review-protocol': 'Ответ reviewer нарушил протокол ревью; повторы reviewer исчерпаны.',
|
|
75
|
+
merge: 'Слияние с веткой интеграции не сошлось.',
|
|
76
|
+
cancelled: 'Работа отменена человеком.',
|
|
77
|
+
budget: 'Бюджет расходов или времени исчерпан либо не определён.',
|
|
78
|
+
unknown: 'Класс отказа не определён.',
|
|
79
|
+
'runtime-missing': 'Назначенный политикой runtime не найден или не отвечает на --version.',
|
|
80
|
+
'controller-busy': 'Очередь ведёт другой процесс controller.',
|
|
81
|
+
'operator-pause': 'Очередь остановлена.',
|
|
82
|
+
'approval-required': 'Граф ждёт ревью и согласования плана.',
|
|
83
|
+
'not-ready': 'Поручение не готово к выдаче.',
|
|
84
|
+
};
|
|
85
|
+
/** Фаза по умолчанию для класса отказа поручения. */
|
|
86
|
+
const failurePhase = {
|
|
87
|
+
'provider-auth': 'implementation',
|
|
88
|
+
environment: 'implementation',
|
|
89
|
+
timeout: 'implementation',
|
|
90
|
+
unknown: 'implementation',
|
|
91
|
+
'empty-result': 'implementation',
|
|
92
|
+
gate: 'gates',
|
|
93
|
+
review: 'review',
|
|
94
|
+
'review-protocol': 'review',
|
|
95
|
+
'stale-base': 'integration',
|
|
96
|
+
merge: 'integration',
|
|
97
|
+
'scope-violation': 'integration',
|
|
98
|
+
budget: 'claim',
|
|
99
|
+
cancelled: 'claim',
|
|
100
|
+
};
|
|
101
|
+
const activePhase = {
|
|
102
|
+
running: 'implementation',
|
|
103
|
+
verifying: 'gates',
|
|
104
|
+
reviewing: 'review',
|
|
105
|
+
integrating: 'integration',
|
|
106
|
+
};
|
|
107
|
+
const message = (cause, ...parts) => clipText([causeText[cause], ...parts.filter((p) => Boolean(p))].join(' '),
|
|
108
|
+
// clipText добавляет «…» сверх предела: итог не длиннее CLIP_DIAGNOSTIC.
|
|
109
|
+
CLIP_DIAGNOSTIC - 1);
|
|
110
|
+
/**
|
|
111
|
+
* Решение движка о повторе, как его принял бы `repairDecision`: класс
|
|
112
|
+
* разрешает повтор, одинаковый отпечаток не исчерпан, бюджет попыток и
|
|
113
|
+
* восстановлений группы не исчерпан. Только описание: ничего не планирует.
|
|
114
|
+
*/
|
|
115
|
+
function retryPlannedOf(input) {
|
|
116
|
+
const { work, repair, maxAttempts } = input;
|
|
117
|
+
if (work.status !== 'failed')
|
|
118
|
+
return false;
|
|
119
|
+
if (work.recovery)
|
|
120
|
+
return work.recovery.status === 'retry' && repair.outlook === 'retry';
|
|
121
|
+
if (repair.outlook !== undefined && repair.outlook !== 'retry')
|
|
122
|
+
return false;
|
|
123
|
+
const rule = repairPolicy[work.failureKind ?? 'unknown'];
|
|
124
|
+
return (rule.action === 'retry' &&
|
|
125
|
+
repair.sameFailureRepairs < rule.repeats &&
|
|
126
|
+
work.attempt < maxAttempts &&
|
|
127
|
+
repair.groupRepairsUsed < repair.groupRepairBudget);
|
|
128
|
+
}
|
|
129
|
+
function workOutcome(input, retry) {
|
|
130
|
+
const { work, control, maxAttempts } = input;
|
|
131
|
+
const kind = work.failureKind ?? 'unknown';
|
|
132
|
+
const phase = input.phase ?? failurePhase[kind];
|
|
133
|
+
const exhausted = `Исчерпано ${work.attempt} из ${maxAttempts} попыток; сброс — решение человека.`;
|
|
134
|
+
if (work.status === 'done')
|
|
135
|
+
return {
|
|
136
|
+
code: 'NOT_READY',
|
|
137
|
+
cause: 'not-ready',
|
|
138
|
+
phase: 'delivery',
|
|
139
|
+
actor: null,
|
|
140
|
+
action: 'none',
|
|
141
|
+
note: 'Поручение принято.',
|
|
142
|
+
};
|
|
143
|
+
if (work.approvalStale)
|
|
144
|
+
return {
|
|
145
|
+
code: 'APPROVAL_STALE',
|
|
146
|
+
cause: 'approval-required',
|
|
147
|
+
phase: 'claim',
|
|
148
|
+
actor: 'lead',
|
|
149
|
+
action: 'review-plan',
|
|
150
|
+
note: work.approvalStale,
|
|
151
|
+
};
|
|
152
|
+
const automatic = input.repair.outlook === 'wait';
|
|
153
|
+
if (work.recovery &&
|
|
154
|
+
!retry &&
|
|
155
|
+
// Исчерпанные попытки — раньше эпизода: движок откажет в повторе по ним.
|
|
156
|
+
!(work.status === 'failed' && work.attempt >= maxAttempts) &&
|
|
157
|
+
(work.status === 'failed' ||
|
|
158
|
+
// Готовую работу эпизод держит, только если не разрешает выдачу (как
|
|
159
|
+
// blocksClaim движка) или разрешённый повтор не выдаётся очередью.
|
|
160
|
+
(work.status === 'ready' &&
|
|
161
|
+
!automatic &&
|
|
162
|
+
(!['retry', 'closed'].includes(work.recovery.status) ||
|
|
163
|
+
control.paused ||
|
|
164
|
+
Boolean(work.hold) ||
|
|
165
|
+
Boolean(work.budgetBlock))))) {
|
|
166
|
+
// Работу ведёт разбор свойства: шаг определяет его статус, а не класс отказа.
|
|
167
|
+
if (!automatic &&
|
|
168
|
+
control.paused &&
|
|
169
|
+
(work.status === 'failed' || (work.status === 'ready' && work.recovery.status === 'retry')) &&
|
|
170
|
+
(work.recovery.status === 'awaiting-lead' || work.recovery.status === 'retry'))
|
|
171
|
+
// Разрешённый повтор не выдаётся, пока очередь стоит: сначала снять паузу.
|
|
172
|
+
return control.pauseReason === 'runtime'
|
|
173
|
+
? {
|
|
174
|
+
code: stopCodeOf(control.pauseFailures?.[0] ?? 'environment'),
|
|
175
|
+
cause: control.pauseFailures?.[0] ?? 'environment',
|
|
176
|
+
phase: 'claim',
|
|
177
|
+
actor: 'user',
|
|
178
|
+
action: control.pauseFailures?.[0] === 'provider-auth' ? 'fix-access' : 'fix-environment',
|
|
179
|
+
note: `Восстановление свойства (${work.recovery.status}) ждёт снятия паузы runtime.`,
|
|
180
|
+
}
|
|
181
|
+
: {
|
|
182
|
+
code: 'PAUSED',
|
|
183
|
+
cause: 'operator-pause',
|
|
184
|
+
phase: 'claim',
|
|
185
|
+
actor: 'user',
|
|
186
|
+
action: 'resume-queue',
|
|
187
|
+
note: `Восстановление свойства (${work.recovery.status}) ждёт снятия паузы.`,
|
|
188
|
+
};
|
|
189
|
+
if (!automatic && work.budgetBlock)
|
|
190
|
+
return {
|
|
191
|
+
code: 'BUDGET_EXHAUSTED',
|
|
192
|
+
cause: 'budget',
|
|
193
|
+
phase: 'claim',
|
|
194
|
+
actor: 'user',
|
|
195
|
+
action: 'raise-budget',
|
|
196
|
+
note: `Восстановление свойства (${work.recovery.status}) не продолжится: ${work.budgetBlock.reason}`,
|
|
197
|
+
};
|
|
198
|
+
return automatic
|
|
199
|
+
? {
|
|
200
|
+
code: stopCodeOf(kind),
|
|
201
|
+
cause: kind,
|
|
202
|
+
phase,
|
|
203
|
+
actor: 'controller',
|
|
204
|
+
action: 'wait',
|
|
205
|
+
note: `Идёт восстановление свойства (${work.recovery.status}): движок продолжит его сам.`,
|
|
206
|
+
}
|
|
207
|
+
: {
|
|
208
|
+
code: stopCodeOf(kind),
|
|
209
|
+
cause: kind,
|
|
210
|
+
phase,
|
|
211
|
+
actor: 'user',
|
|
212
|
+
action: 'user-decision',
|
|
213
|
+
note: `Восстановление свойства (${work.recovery.status}) ждёт решения человека.`,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
if (work.status === 'failed' &&
|
|
217
|
+
!retry &&
|
|
218
|
+
work.attempt < maxAttempts &&
|
|
219
|
+
input.repair.outlook === 'wait')
|
|
220
|
+
return {
|
|
221
|
+
code: stopCodeOf(kind),
|
|
222
|
+
cause: kind,
|
|
223
|
+
phase,
|
|
224
|
+
actor: 'controller',
|
|
225
|
+
action: 'wait',
|
|
226
|
+
note: 'Движок сначала занят другим поручением группы.',
|
|
227
|
+
};
|
|
228
|
+
if (work.status === 'failed') {
|
|
229
|
+
if (work.attempt >= maxAttempts)
|
|
230
|
+
return {
|
|
231
|
+
code: 'ATTEMPTS_EXHAUSTED',
|
|
232
|
+
cause: kind,
|
|
233
|
+
phase: 'claim',
|
|
234
|
+
actor: 'user',
|
|
235
|
+
action: 'reset-attempts',
|
|
236
|
+
note: exhausted,
|
|
237
|
+
};
|
|
238
|
+
if (retry)
|
|
239
|
+
return {
|
|
240
|
+
code: stopCodeOf(kind),
|
|
241
|
+
cause: kind,
|
|
242
|
+
phase,
|
|
243
|
+
actor: 'controller',
|
|
244
|
+
action: 'retry',
|
|
245
|
+
note: 'Движок назначит повтор в пределах бюджетов.',
|
|
246
|
+
};
|
|
247
|
+
switch (kind) {
|
|
248
|
+
case 'provider-auth':
|
|
249
|
+
return {
|
|
250
|
+
code: 'RUNTIME_UNAVAILABLE',
|
|
251
|
+
cause: kind,
|
|
252
|
+
phase,
|
|
253
|
+
actor: 'user',
|
|
254
|
+
action: 'fix-access',
|
|
255
|
+
};
|
|
256
|
+
case 'environment':
|
|
257
|
+
case 'timeout':
|
|
258
|
+
return {
|
|
259
|
+
code: 'RUNTIME_UNAVAILABLE',
|
|
260
|
+
cause: kind,
|
|
261
|
+
phase,
|
|
262
|
+
actor: 'user',
|
|
263
|
+
action: 'fix-environment',
|
|
264
|
+
};
|
|
265
|
+
case 'review-protocol':
|
|
266
|
+
case 'unknown':
|
|
267
|
+
return {
|
|
268
|
+
code: stopCodeOf(kind),
|
|
269
|
+
cause: kind,
|
|
270
|
+
phase,
|
|
271
|
+
actor: 'user',
|
|
272
|
+
action: 'user-decision',
|
|
273
|
+
};
|
|
274
|
+
case 'budget':
|
|
275
|
+
return {
|
|
276
|
+
code: 'BUDGET_EXHAUSTED',
|
|
277
|
+
cause: kind,
|
|
278
|
+
phase: 'claim',
|
|
279
|
+
actor: 'user',
|
|
280
|
+
action: 'raise-budget',
|
|
281
|
+
};
|
|
282
|
+
case 'cancelled':
|
|
283
|
+
// Поручение со статусом failed и классом cancelled: отмена не повторяется.
|
|
284
|
+
return {
|
|
285
|
+
code: stopCodeOf(kind),
|
|
286
|
+
cause: kind,
|
|
287
|
+
phase,
|
|
288
|
+
actor: 'lead',
|
|
289
|
+
action: 'replan-dependents',
|
|
290
|
+
};
|
|
291
|
+
default:
|
|
292
|
+
return {
|
|
293
|
+
code: stopCodeOf(kind),
|
|
294
|
+
cause: kind,
|
|
295
|
+
phase,
|
|
296
|
+
actor: 'lead',
|
|
297
|
+
action: 'diagnose-failure',
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (work.status === 'ready' && work.waitingOn?.length)
|
|
302
|
+
return {
|
|
303
|
+
code: 'NOT_READY',
|
|
304
|
+
cause: 'not-ready',
|
|
305
|
+
phase: 'claim',
|
|
306
|
+
actor: 'lead',
|
|
307
|
+
action: 'diagnose-failure',
|
|
308
|
+
note: `Ждёт ${work.waitingOn.join(', ')}: на них движок остановится; следующий шаг — по их диагнозу.`,
|
|
309
|
+
};
|
|
310
|
+
if (work.status === 'cancelled')
|
|
311
|
+
return {
|
|
312
|
+
code: 'CANCELLED',
|
|
313
|
+
cause: 'cancelled',
|
|
314
|
+
phase: 'claim',
|
|
315
|
+
actor: 'lead',
|
|
316
|
+
action: 'replan-dependents',
|
|
317
|
+
};
|
|
318
|
+
if (work.status === 'draft')
|
|
319
|
+
return {
|
|
320
|
+
code: 'APPROVAL_REQUIRED',
|
|
321
|
+
cause: 'approval-required',
|
|
322
|
+
phase: 'claim',
|
|
323
|
+
actor: 'lead',
|
|
324
|
+
action: 'review-plan',
|
|
325
|
+
};
|
|
326
|
+
if (work.hold)
|
|
327
|
+
return {
|
|
328
|
+
code: 'NOT_READY',
|
|
329
|
+
cause: 'not-ready',
|
|
330
|
+
phase: 'claim',
|
|
331
|
+
actor: 'controller',
|
|
332
|
+
action: 'wait',
|
|
333
|
+
note: `Выдача удержана операцией ${work.hold.operation}: ${work.hold.reason}`,
|
|
334
|
+
};
|
|
335
|
+
if (work.budgetBlock)
|
|
336
|
+
return {
|
|
337
|
+
code: 'BUDGET_EXHAUSTED',
|
|
338
|
+
cause: 'budget',
|
|
339
|
+
phase: 'claim',
|
|
340
|
+
actor: 'user',
|
|
341
|
+
action: 'raise-budget',
|
|
342
|
+
note: work.budgetBlock.reason,
|
|
343
|
+
};
|
|
344
|
+
if (control.paused && (control.pauseReason === 'operator' || control.pauseReason === 'shutdown'))
|
|
345
|
+
return {
|
|
346
|
+
code: 'PAUSED',
|
|
347
|
+
cause: 'operator-pause',
|
|
348
|
+
phase: 'claim',
|
|
349
|
+
actor: 'user',
|
|
350
|
+
action: 'resume-queue',
|
|
351
|
+
note: 'Продолжение — harness resume.',
|
|
352
|
+
};
|
|
353
|
+
if (control.paused && control.pauseReason === 'runtime') {
|
|
354
|
+
const paused = control.pauseFailures?.[0] ?? 'environment';
|
|
355
|
+
return {
|
|
356
|
+
code: stopCodeOf(paused),
|
|
357
|
+
cause: paused,
|
|
358
|
+
phase: 'claim',
|
|
359
|
+
actor: 'user',
|
|
360
|
+
action: paused === 'provider-auth' ? 'fix-access' : 'fix-environment',
|
|
361
|
+
note: `Выдача остановлена отказом класса ${paused}; после исправления — harness resume.`,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
if (control.paused &&
|
|
365
|
+
(control.pauseReason === 'reconfigure' || control.pauseReason === 'base-check'))
|
|
366
|
+
return {
|
|
367
|
+
code: 'PAUSED',
|
|
368
|
+
cause: 'not-ready',
|
|
369
|
+
phase: 'claim',
|
|
370
|
+
actor: 'controller',
|
|
371
|
+
action: 'wait',
|
|
372
|
+
note: `Очередь ждёт операции ${control.pauseReason}.`,
|
|
373
|
+
};
|
|
374
|
+
const active = activePhase[work.status];
|
|
375
|
+
if (active)
|
|
376
|
+
return {
|
|
377
|
+
code: 'NOT_READY',
|
|
378
|
+
cause: 'not-ready',
|
|
379
|
+
phase: active,
|
|
380
|
+
actor: 'controller',
|
|
381
|
+
action: 'wait',
|
|
382
|
+
note: `Поручение выполняется (${work.status}).`,
|
|
383
|
+
};
|
|
384
|
+
if (work.status === 'ready' && work.attempt >= maxAttempts)
|
|
385
|
+
return {
|
|
386
|
+
code: 'ATTEMPTS_EXHAUSTED',
|
|
387
|
+
cause: kind,
|
|
388
|
+
phase: 'claim',
|
|
389
|
+
actor: 'user',
|
|
390
|
+
action: 'reset-attempts',
|
|
391
|
+
note: exhausted,
|
|
392
|
+
};
|
|
393
|
+
return {
|
|
394
|
+
code: 'NOT_READY',
|
|
395
|
+
cause: 'not-ready',
|
|
396
|
+
phase: 'claim',
|
|
397
|
+
actor: 'controller',
|
|
398
|
+
action: 'wait',
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function errorOutcome(code) {
|
|
402
|
+
switch (code) {
|
|
403
|
+
case 'CONTROLLER_BUSY':
|
|
404
|
+
return { code, cause: 'controller-busy', phase: 'claim', actor: 'lead', action: 'wait' };
|
|
405
|
+
case 'PAUSED':
|
|
406
|
+
return {
|
|
407
|
+
code,
|
|
408
|
+
cause: 'operator-pause',
|
|
409
|
+
phase: 'claim',
|
|
410
|
+
actor: 'user',
|
|
411
|
+
action: 'resume-queue',
|
|
412
|
+
};
|
|
413
|
+
case 'APPROVAL_REQUIRED':
|
|
414
|
+
case 'APPROVAL_STALE':
|
|
415
|
+
return {
|
|
416
|
+
code,
|
|
417
|
+
cause: 'approval-required',
|
|
418
|
+
phase: 'claim',
|
|
419
|
+
actor: 'lead',
|
|
420
|
+
action: 'review-plan',
|
|
421
|
+
};
|
|
422
|
+
case 'GATE_FAILED':
|
|
423
|
+
return { code, cause: 'gate', phase: 'gates', actor: 'lead', action: 'diagnose-failure' };
|
|
424
|
+
case 'REVIEW_REJECTED':
|
|
425
|
+
return { code, cause: 'review', phase: 'review', actor: 'lead', action: 'diagnose-failure' };
|
|
426
|
+
case 'REVIEW_PROTOCOL_INVALID':
|
|
427
|
+
return {
|
|
428
|
+
code,
|
|
429
|
+
cause: 'review-protocol',
|
|
430
|
+
phase: 'review',
|
|
431
|
+
actor: 'user',
|
|
432
|
+
action: 'user-decision',
|
|
433
|
+
};
|
|
434
|
+
case 'SCOPE_VIOLATION':
|
|
435
|
+
return {
|
|
436
|
+
code,
|
|
437
|
+
cause: 'scope-violation',
|
|
438
|
+
phase: 'integration',
|
|
439
|
+
actor: 'lead',
|
|
440
|
+
action: 'diagnose-failure',
|
|
441
|
+
};
|
|
442
|
+
case 'BUDGET_EXHAUSTED':
|
|
443
|
+
case 'BUDGET_UNKNOWN':
|
|
444
|
+
return { code, cause: 'budget', phase: 'claim', actor: 'user', action: 'raise-budget' };
|
|
445
|
+
case 'ATTEMPTS_EXHAUSTED':
|
|
446
|
+
return { code, cause: 'unknown', phase: 'claim', actor: 'user', action: 'reset-attempts' };
|
|
447
|
+
case 'RUNTIME_UNAVAILABLE':
|
|
448
|
+
return {
|
|
449
|
+
code,
|
|
450
|
+
cause: 'environment',
|
|
451
|
+
phase: 'preflight',
|
|
452
|
+
actor: 'user',
|
|
453
|
+
action: 'fix-environment',
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
switch (errorCodes[code]) {
|
|
457
|
+
case 'input':
|
|
458
|
+
return {
|
|
459
|
+
code,
|
|
460
|
+
cause: 'not-ready',
|
|
461
|
+
phase: 'preflight',
|
|
462
|
+
actor: 'lead',
|
|
463
|
+
action: 'diagnose-failure',
|
|
464
|
+
};
|
|
465
|
+
case 'refused':
|
|
466
|
+
return {
|
|
467
|
+
code,
|
|
468
|
+
cause: 'not-ready',
|
|
469
|
+
phase: 'claim',
|
|
470
|
+
actor: 'lead',
|
|
471
|
+
action: 'diagnose-failure',
|
|
472
|
+
};
|
|
473
|
+
case 'infrastructure':
|
|
474
|
+
return {
|
|
475
|
+
code,
|
|
476
|
+
cause: 'environment',
|
|
477
|
+
phase: 'preflight',
|
|
478
|
+
actor: 'user',
|
|
479
|
+
action: 'fix-environment',
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Объяснение остановки (OP-DIAG-05): только чтение, ничего не планирует.
|
|
485
|
+
* Класс отказа берётся из сохранённого `failureKind` — текст ошибки здесь не
|
|
486
|
+
* разбирается и не переклассифицируется (исторический `unknown` остаётся им).
|
|
487
|
+
*/
|
|
488
|
+
export function explainStop(input) {
|
|
489
|
+
if (input.kind === 'runtime') {
|
|
490
|
+
const { runtime, available, reason } = input.runtime;
|
|
491
|
+
if (!available)
|
|
492
|
+
return {
|
|
493
|
+
code: 'RUNTIME_UNAVAILABLE',
|
|
494
|
+
cause: 'runtime-missing',
|
|
495
|
+
phase: 'preflight',
|
|
496
|
+
actor: 'user',
|
|
497
|
+
action: 'fix-environment',
|
|
498
|
+
retryPlanned: false,
|
|
499
|
+
message: message('runtime-missing', `Runtime: ${runtime}.`, reason),
|
|
500
|
+
evidence: [{ kind: 'doctor', id: runtime }],
|
|
501
|
+
};
|
|
502
|
+
return {
|
|
503
|
+
code: 'NOT_READY',
|
|
504
|
+
cause: 'not-ready',
|
|
505
|
+
phase: 'preflight',
|
|
506
|
+
actor: null,
|
|
507
|
+
action: 'none',
|
|
508
|
+
retryPlanned: false,
|
|
509
|
+
message: clipText(`Runtime ${runtime} доступен.`, CLIP_DIAGNOSTIC - 1),
|
|
510
|
+
evidence: [],
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
if (input.kind === 'error') {
|
|
514
|
+
const outcome = errorOutcome(input.error.code);
|
|
515
|
+
return {
|
|
516
|
+
...outcome,
|
|
517
|
+
retryPlanned: false,
|
|
518
|
+
message: message(outcome.cause, input.error.message),
|
|
519
|
+
evidence: [],
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
const retryPlanned = retryPlannedOf(input);
|
|
523
|
+
const { note, ...outcome } = workOutcome(input, retryPlanned);
|
|
524
|
+
return {
|
|
525
|
+
...outcome,
|
|
526
|
+
retryPlanned: outcome.action === 'retry',
|
|
527
|
+
message: message(outcome.cause, note, input.work.failure ? `Отказ: ${input.work.failure}` : undefined),
|
|
528
|
+
evidence: (input.evidence ?? []).slice(-20).map((e) => ({ ...e })),
|
|
529
|
+
workId: input.work.id,
|
|
530
|
+
...(input.runId ? { runId: input.runId } : {}),
|
|
531
|
+
};
|
|
532
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Stats } from 'node:fs';
|
|
2
|
+
import type { fileConflicts } from '../contracts/project.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Безопасная подготовка файлов: план → create-only применение. Ничего
|
|
5
|
+
* существующего не перезаписывается, через symlink и вне корня не пишется.
|
|
6
|
+
*/
|
|
7
|
+
export type FileConflict = (typeof fileConflicts)[number];
|
|
8
|
+
export interface FileIntent {
|
|
9
|
+
/** Абсолютный путь. */
|
|
10
|
+
path: string;
|
|
11
|
+
content: string;
|
|
12
|
+
/** По умолчанию `preserve`. */
|
|
13
|
+
onExisting?: 'preserve' | 'require-identical';
|
|
14
|
+
}
|
|
15
|
+
export interface FileWriteInput {
|
|
16
|
+
files: FileIntent[];
|
|
17
|
+
root?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface FilePlanEntry {
|
|
20
|
+
path: string;
|
|
21
|
+
action: 'create' | 'preserve' | 'conflict';
|
|
22
|
+
conflict?: FileConflict;
|
|
23
|
+
/** Путь, вызвавший конфликт (symlink-предок, предок-файл). */
|
|
24
|
+
conflictPath?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface FilePlan {
|
|
27
|
+
entries: FilePlanEntry[];
|
|
28
|
+
conflicts: number;
|
|
29
|
+
root?: string;
|
|
30
|
+
}
|
|
31
|
+
/** `lstat`; отсутствующий путь — undefined, прочие ошибки — как есть. */
|
|
32
|
+
export declare function inspectPath(path: string): Promise<Stats | undefined>;
|
|
33
|
+
/** Отказ PATH_CONFLICT, если путь или предок — symlink, предок не каталог или путь вне root. */
|
|
34
|
+
export declare function checkDestination(path: string, options?: {
|
|
35
|
+
root?: string;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
/** Относительные пути обычных файлов каталога (рекурсивно). */
|
|
38
|
+
export declare function listRegularFiles(dir: string): Promise<string[]>;
|
|
39
|
+
/** План записей; конфликты не бросаются — агент видит их все сразу. */
|
|
40
|
+
export declare function planFileWrites(input: FileWriteInput): Promise<FilePlan>;
|
|
41
|
+
/** Применение плана: только создание, в порядке `files`. */
|
|
42
|
+
export declare function applyFileWrites(plan: FilePlan, files: FileIntent[]): Promise<{
|
|
43
|
+
created: string[];
|
|
44
|
+
preserved: string[];
|
|
45
|
+
}>;
|