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,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Один вызов Relay-2 CLI: argv-массив без shell, ограниченные вывод и время,
|
|
3
|
+
* завершение всей группы процессов при таймауте, отмене или переполнении.
|
|
4
|
+
* Результат возвращается только после `close`: дочерний процесс к этому
|
|
5
|
+
* моменту завершён и собран (нет зомби), pipes закрыты.
|
|
6
|
+
*/
|
|
7
|
+
export interface CliRun {
|
|
8
|
+
/** Процесс так и не стартовал (нет binary, нет прав): запрос не ушёл. */
|
|
9
|
+
spawnError?: NodeJS.ErrnoException;
|
|
10
|
+
/** Процесс стартовал (запрос мог дойти до backend). */
|
|
11
|
+
started: boolean;
|
|
12
|
+
code: number | null;
|
|
13
|
+
signal: NodeJS.Signals | null;
|
|
14
|
+
stdout: string;
|
|
15
|
+
stderr: string;
|
|
16
|
+
timedOut: boolean;
|
|
17
|
+
aborted: boolean;
|
|
18
|
+
/** Суммарный вывод превысил лимит; процесс остановлен. */
|
|
19
|
+
oversized: boolean;
|
|
20
|
+
durationMs: number;
|
|
21
|
+
pid?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface CliRunOptions {
|
|
24
|
+
cwd: string;
|
|
25
|
+
env: Record<string, string>;
|
|
26
|
+
timeoutMs: number;
|
|
27
|
+
maxOutputBytes: number;
|
|
28
|
+
/** Пауза между SIGTERM и SIGKILL группе. */
|
|
29
|
+
killGraceMs: number;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}
|
|
32
|
+
export declare function runCli(file: string, args: string[], options: CliRunOptions): Promise<CliRun>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export function runCli(file, args, options) {
|
|
3
|
+
const startedAt = Date.now();
|
|
4
|
+
if (options.signal?.aborted)
|
|
5
|
+
return Promise.resolve({
|
|
6
|
+
started: false,
|
|
7
|
+
code: null,
|
|
8
|
+
signal: null,
|
|
9
|
+
stdout: '',
|
|
10
|
+
stderr: '',
|
|
11
|
+
timedOut: false,
|
|
12
|
+
aborted: true,
|
|
13
|
+
oversized: false,
|
|
14
|
+
durationMs: 0,
|
|
15
|
+
});
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const posix = process.platform !== 'win32';
|
|
18
|
+
const child = spawn(file, args, {
|
|
19
|
+
cwd: options.cwd,
|
|
20
|
+
env: options.env,
|
|
21
|
+
shell: false,
|
|
22
|
+
// Своя группа: сигнал `-pid` достаёт и потомков binary.
|
|
23
|
+
detached: posix,
|
|
24
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
25
|
+
windowsHide: true,
|
|
26
|
+
});
|
|
27
|
+
const out = [];
|
|
28
|
+
const err = [];
|
|
29
|
+
let bytes = 0;
|
|
30
|
+
let timedOut = false;
|
|
31
|
+
let aborted = false;
|
|
32
|
+
let oversized = false;
|
|
33
|
+
let stopping = false;
|
|
34
|
+
let spawnError;
|
|
35
|
+
let killTimer;
|
|
36
|
+
const signalGroup = (sig) => {
|
|
37
|
+
try {
|
|
38
|
+
if (child.pid && posix)
|
|
39
|
+
process.kill(-child.pid, sig);
|
|
40
|
+
else
|
|
41
|
+
child.kill(sig);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
/* Группа уже завершилась. */
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const stop = () => {
|
|
48
|
+
if (stopping)
|
|
49
|
+
return;
|
|
50
|
+
stopping = true;
|
|
51
|
+
signalGroup('SIGTERM');
|
|
52
|
+
killTimer = setTimeout(() => signalGroup('SIGKILL'), options.killGraceMs);
|
|
53
|
+
};
|
|
54
|
+
const take = (chunks) => (d) => {
|
|
55
|
+
if (oversized)
|
|
56
|
+
return;
|
|
57
|
+
bytes += d.length;
|
|
58
|
+
if (bytes > options.maxOutputBytes) {
|
|
59
|
+
oversized = true;
|
|
60
|
+
stop();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
chunks.push(d);
|
|
64
|
+
};
|
|
65
|
+
child.stdout.on('data', take(out));
|
|
66
|
+
child.stderr.on('data', take(err));
|
|
67
|
+
const onAbort = () => {
|
|
68
|
+
aborted = true;
|
|
69
|
+
stop();
|
|
70
|
+
};
|
|
71
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
72
|
+
const timer = setTimeout(() => {
|
|
73
|
+
timedOut = true;
|
|
74
|
+
stop();
|
|
75
|
+
}, options.timeoutMs);
|
|
76
|
+
let done = false;
|
|
77
|
+
child.once('error', (e) => {
|
|
78
|
+
// `error` без pid — процесс не стартовал (ENOENT/EACCES): запрос не ушёл.
|
|
79
|
+
if (child.pid)
|
|
80
|
+
return;
|
|
81
|
+
spawnError = e;
|
|
82
|
+
finish(null, null);
|
|
83
|
+
});
|
|
84
|
+
child.once('close', (code, sig) => finish(code, sig));
|
|
85
|
+
const finish = (code, sig) => {
|
|
86
|
+
if (done)
|
|
87
|
+
return;
|
|
88
|
+
done = true;
|
|
89
|
+
clearTimeout(timer);
|
|
90
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
91
|
+
// Лидер группы вышел; оставшиеся потомки (если были) получают SIGKILL
|
|
92
|
+
// сразу, а не по таймеру.
|
|
93
|
+
if (stopping || code !== 0)
|
|
94
|
+
signalGroup('SIGKILL');
|
|
95
|
+
if (killTimer)
|
|
96
|
+
clearTimeout(killTimer);
|
|
97
|
+
resolve({
|
|
98
|
+
...(spawnError ? { spawnError } : {}),
|
|
99
|
+
started: Boolean(child.pid) && !spawnError,
|
|
100
|
+
code,
|
|
101
|
+
signal: sig,
|
|
102
|
+
stdout: Buffer.concat(out).toString('utf8'),
|
|
103
|
+
stderr: Buffer.concat(err).toString('utf8'),
|
|
104
|
+
timedOut,
|
|
105
|
+
aborted,
|
|
106
|
+
oversized,
|
|
107
|
+
durationMs: Date.now() - startedAt,
|
|
108
|
+
...(child.pid ? { pid: child.pid } : {}),
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { TransportErrorKind } from '../connector/transport.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Договор вывода Relay-2 CLI (`--format json`), проверенный на сборке
|
|
5
|
+
* a3ee804: успех — одна JSON-строка `{ok:true,data,meta?}` в stdout и exit 0;
|
|
6
|
+
* отказ — `{ok:false,error:{code,message,details?}}` в stderr и ненулевой exit.
|
|
7
|
+
* Схемы проверяют только поля, которые читает адаптер; лишние поля допустимы.
|
|
8
|
+
*/
|
|
9
|
+
export declare const successSchema: z.ZodObject<{
|
|
10
|
+
ok: z.ZodLiteral<true>;
|
|
11
|
+
data: z.ZodUnknown;
|
|
12
|
+
meta: z.ZodOptional<z.ZodUnknown>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const failureSchema: z.ZodObject<{
|
|
15
|
+
ok: z.ZodLiteral<false>;
|
|
16
|
+
error: z.ZodObject<{
|
|
17
|
+
code: z.ZodString;
|
|
18
|
+
message: z.ZodString;
|
|
19
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export declare const columnSchema: z.ZodEnum<{
|
|
23
|
+
ready: "ready";
|
|
24
|
+
review: "review";
|
|
25
|
+
cancelled: "cancelled";
|
|
26
|
+
done: "done";
|
|
27
|
+
"in-progress": "in-progress";
|
|
28
|
+
inbox: "inbox";
|
|
29
|
+
}>;
|
|
30
|
+
export declare const criterionSchema: z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
title: z.ZodString;
|
|
33
|
+
summary: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
|
|
34
|
+
description: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
|
|
35
|
+
completed: z.ZodBoolean;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export declare const commentSchema: z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
title: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
|
|
40
|
+
body: z.ZodString;
|
|
41
|
+
createdAt: z.ZodString;
|
|
42
|
+
createdBy: z.ZodString;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export declare const taskSchema: z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
kind: z.ZodLiteral<string>;
|
|
47
|
+
key: z.ZodString;
|
|
48
|
+
revision: z.ZodNumber;
|
|
49
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
50
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
51
|
+
data: z.ZodObject<{
|
|
52
|
+
title: z.ZodString;
|
|
53
|
+
description: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
|
|
54
|
+
column: z.ZodEnum<{
|
|
55
|
+
ready: "ready";
|
|
56
|
+
review: "review";
|
|
57
|
+
cancelled: "cancelled";
|
|
58
|
+
done: "done";
|
|
59
|
+
"in-progress": "in-progress";
|
|
60
|
+
inbox: "inbox";
|
|
61
|
+
}>;
|
|
62
|
+
parentId: z.ZodNullable<z.ZodString>;
|
|
63
|
+
dependencies: z.ZodArray<z.ZodString>;
|
|
64
|
+
acceptanceCriteria: z.ZodArray<z.ZodObject<{
|
|
65
|
+
id: z.ZodString;
|
|
66
|
+
title: z.ZodString;
|
|
67
|
+
summary: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
|
|
68
|
+
description: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
|
|
69
|
+
completed: z.ZodBoolean;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
comments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
title: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
|
|
74
|
+
body: z.ZodString;
|
|
75
|
+
createdAt: z.ZodString;
|
|
76
|
+
createdBy: z.ZodString;
|
|
77
|
+
}, z.core.$strip>>>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
export declare const progressSchema: z.ZodObject<{
|
|
81
|
+
completed: z.ZodBoolean;
|
|
82
|
+
canComplete: z.ZodBoolean;
|
|
83
|
+
blockers: z.ZodArray<z.ZodString>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export declare const documentSchema: z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
kind: z.ZodLiteral<string>;
|
|
88
|
+
key: z.ZodString;
|
|
89
|
+
revision: z.ZodNumber;
|
|
90
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
91
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
92
|
+
data: z.ZodObject<{
|
|
93
|
+
name: z.ZodString;
|
|
94
|
+
body: z.ZodString;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
export declare const sessionSchema: z.ZodObject<{
|
|
98
|
+
id: z.ZodString;
|
|
99
|
+
kind: z.ZodLiteral<string>;
|
|
100
|
+
key: z.ZodString;
|
|
101
|
+
revision: z.ZodNumber;
|
|
102
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
103
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
104
|
+
data: z.ZodObject<{
|
|
105
|
+
title: z.ZodString;
|
|
106
|
+
description: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
|
|
107
|
+
status: z.ZodEnum<{
|
|
108
|
+
open: "open";
|
|
109
|
+
cancelled: "cancelled";
|
|
110
|
+
pending: "pending";
|
|
111
|
+
completed: "completed";
|
|
112
|
+
paused: "paused";
|
|
113
|
+
}>;
|
|
114
|
+
currentRunId: z.ZodNullable<z.ZodString>;
|
|
115
|
+
parentSessionId: z.ZodNullable<z.ZodString>;
|
|
116
|
+
result: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string, string | null | undefined>>;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
export declare const checkpointSchema: z.ZodObject<{
|
|
120
|
+
id: z.ZodString;
|
|
121
|
+
kind: z.ZodLiteral<string>;
|
|
122
|
+
key: z.ZodString;
|
|
123
|
+
revision: z.ZodNumber;
|
|
124
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
125
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
126
|
+
data: z.ZodObject<{
|
|
127
|
+
kind: z.ZodEnum<{
|
|
128
|
+
result: "result";
|
|
129
|
+
cancel: "cancel";
|
|
130
|
+
intent: "intent";
|
|
131
|
+
progress: "progress";
|
|
132
|
+
}>;
|
|
133
|
+
sessionId: z.ZodString;
|
|
134
|
+
runId: z.ZodString;
|
|
135
|
+
intentId: z.ZodNullable<z.ZodString>;
|
|
136
|
+
title: z.ZodString;
|
|
137
|
+
body: z.ZodString;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
export declare const storageStatusSchema: z.ZodObject<{
|
|
141
|
+
projectId: z.ZodString;
|
|
142
|
+
databasePath: z.ZodString;
|
|
143
|
+
generation: z.ZodNumber;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
export declare const projectSchema: z.ZodObject<{
|
|
146
|
+
id: z.ZodString;
|
|
147
|
+
kind: z.ZodLiteral<string>;
|
|
148
|
+
key: z.ZodString;
|
|
149
|
+
revision: z.ZodNumber;
|
|
150
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
151
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
152
|
+
data: z.ZodObject<{
|
|
153
|
+
name: z.ZodString;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
}, z.core.$strip>;
|
|
156
|
+
export declare const doctorSchema: z.ZodObject<{
|
|
157
|
+
projectId: z.ZodString;
|
|
158
|
+
generation: z.ZodNumber;
|
|
159
|
+
valid: z.ZodBoolean;
|
|
160
|
+
issues: z.ZodArray<z.ZodUnknown>;
|
|
161
|
+
}, z.core.$strip>;
|
|
162
|
+
export declare const pageMetaSchema: z.ZodObject<{
|
|
163
|
+
page: z.ZodObject<{
|
|
164
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
165
|
+
consistency: z.ZodOptional<z.ZodString>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
export declare const itemsSchema: z.ZodObject<{
|
|
169
|
+
items: z.ZodArray<z.ZodUnknown>;
|
|
170
|
+
}, z.core.$strip>;
|
|
171
|
+
/** Стабильный код Relay-2 → класс отказа транспорта. Exit code — только грубый класс. */
|
|
172
|
+
export declare function classifyCode(code: string, exit: number | null, mutation: boolean): TransportErrorKind;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Договор вывода Relay-2 CLI (`--format json`), проверенный на сборке
|
|
4
|
+
* a3ee804: успех — одна JSON-строка `{ok:true,data,meta?}` в stdout и exit 0;
|
|
5
|
+
* отказ — `{ok:false,error:{code,message,details?}}` в stderr и ненулевой exit.
|
|
6
|
+
* Схемы проверяют только поля, которые читает адаптер; лишние поля допустимы.
|
|
7
|
+
*/
|
|
8
|
+
export const successSchema = z.object({
|
|
9
|
+
ok: z.literal(true),
|
|
10
|
+
data: z.unknown(),
|
|
11
|
+
meta: z.unknown().optional(),
|
|
12
|
+
});
|
|
13
|
+
export const failureSchema = z.object({
|
|
14
|
+
ok: z.literal(false),
|
|
15
|
+
error: z.object({
|
|
16
|
+
code: z.string().min(1),
|
|
17
|
+
message: z.string(),
|
|
18
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
const nullableText = z
|
|
22
|
+
.string()
|
|
23
|
+
.nullable()
|
|
24
|
+
.optional()
|
|
25
|
+
.transform((v) => v ?? '');
|
|
26
|
+
export const columnSchema = z.enum([
|
|
27
|
+
'inbox',
|
|
28
|
+
'ready',
|
|
29
|
+
'in-progress',
|
|
30
|
+
'review',
|
|
31
|
+
'done',
|
|
32
|
+
'cancelled',
|
|
33
|
+
]);
|
|
34
|
+
/** Общий envelope записи: `{id, kind, key, revision, …, data}`. */
|
|
35
|
+
const envelope = (kind, data) => z.object({
|
|
36
|
+
id: z.string().min(1),
|
|
37
|
+
kind: z.literal(kind),
|
|
38
|
+
key: z.string().min(1),
|
|
39
|
+
revision: z.number().int().positive(),
|
|
40
|
+
createdAt: z.string().optional(),
|
|
41
|
+
createdBy: z.string().optional(),
|
|
42
|
+
data,
|
|
43
|
+
});
|
|
44
|
+
export const criterionSchema = z.object({
|
|
45
|
+
id: z.string().min(1),
|
|
46
|
+
title: z.string(),
|
|
47
|
+
summary: nullableText,
|
|
48
|
+
description: nullableText,
|
|
49
|
+
completed: z.boolean(),
|
|
50
|
+
});
|
|
51
|
+
export const commentSchema = z.object({
|
|
52
|
+
id: z.string().min(1),
|
|
53
|
+
title: nullableText,
|
|
54
|
+
body: z.string(),
|
|
55
|
+
createdAt: z.string(),
|
|
56
|
+
createdBy: z.string(),
|
|
57
|
+
});
|
|
58
|
+
export const taskSchema = envelope('task', z.object({
|
|
59
|
+
title: z.string(),
|
|
60
|
+
description: nullableText,
|
|
61
|
+
column: columnSchema,
|
|
62
|
+
parentId: z.string().nullable(),
|
|
63
|
+
dependencies: z.array(z.string()),
|
|
64
|
+
acceptanceCriteria: z.array(criterionSchema),
|
|
65
|
+
comments: z.array(commentSchema).optional(),
|
|
66
|
+
}));
|
|
67
|
+
export const progressSchema = z.object({
|
|
68
|
+
completed: z.boolean(),
|
|
69
|
+
canComplete: z.boolean(),
|
|
70
|
+
blockers: z.array(z.string()),
|
|
71
|
+
});
|
|
72
|
+
export const documentSchema = envelope('document', z.object({ name: z.string(), body: z.string() }));
|
|
73
|
+
export const sessionSchema = envelope('work-session', z.object({
|
|
74
|
+
title: z.string(),
|
|
75
|
+
description: nullableText,
|
|
76
|
+
status: z.enum(['pending', 'open', 'paused', 'completed', 'cancelled']),
|
|
77
|
+
currentRunId: z.string().nullable(),
|
|
78
|
+
parentSessionId: z.string().nullable(),
|
|
79
|
+
result: nullableText,
|
|
80
|
+
}));
|
|
81
|
+
export const checkpointSchema = envelope('work-checkpoint', z.object({
|
|
82
|
+
kind: z.enum(['intent', 'progress', 'result', 'cancel']),
|
|
83
|
+
sessionId: z.string().min(1),
|
|
84
|
+
runId: z.string().min(1),
|
|
85
|
+
intentId: z.string().nullable(),
|
|
86
|
+
title: z.string(),
|
|
87
|
+
body: z.string(),
|
|
88
|
+
}));
|
|
89
|
+
export const storageStatusSchema = z.object({
|
|
90
|
+
projectId: z.string().min(1),
|
|
91
|
+
databasePath: z.string().min(1),
|
|
92
|
+
generation: z.number().int().nonnegative(),
|
|
93
|
+
});
|
|
94
|
+
export const projectSchema = envelope('project', z.object({ name: z.string() }));
|
|
95
|
+
export const doctorSchema = z.object({
|
|
96
|
+
projectId: z.string().min(1),
|
|
97
|
+
generation: z.number().int().nonnegative(),
|
|
98
|
+
valid: z.boolean(),
|
|
99
|
+
issues: z.array(z.unknown()),
|
|
100
|
+
});
|
|
101
|
+
export const pageMetaSchema = z.object({
|
|
102
|
+
page: z.object({
|
|
103
|
+
nextCursor: z.string().min(1).nullable(),
|
|
104
|
+
consistency: z.string().optional(),
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
107
|
+
export const itemsSchema = z.object({ items: z.array(z.unknown()) });
|
|
108
|
+
/** Стабильный код Relay-2 → класс отказа транспорта. Exit code — только грубый класс. */
|
|
109
|
+
export function classifyCode(code, exit, mutation) {
|
|
110
|
+
switch (code) {
|
|
111
|
+
case 'REVISION_CONFLICT':
|
|
112
|
+
case 'SNAPSHOT_CONFLICT':
|
|
113
|
+
case 'CONFLICT':
|
|
114
|
+
case 'STORAGE_BUSY':
|
|
115
|
+
return 'conflict';
|
|
116
|
+
case 'TASK_INCOMPLETE':
|
|
117
|
+
case 'TASK_DONE':
|
|
118
|
+
case 'TASK_CYCLE':
|
|
119
|
+
case 'ACTOR_REQUIRED':
|
|
120
|
+
case 'CONFLICTING_OPTIONS':
|
|
121
|
+
case 'PROJECT_REQUIRED':
|
|
122
|
+
case 'WORKSPACE_REQUIRED':
|
|
123
|
+
case 'INVALID_CONFIG':
|
|
124
|
+
return 'refused';
|
|
125
|
+
case 'NOT_FOUND':
|
|
126
|
+
case 'PROJECT_NOT_FOUND':
|
|
127
|
+
case 'CONFIG_NOT_FOUND':
|
|
128
|
+
return 'not-found';
|
|
129
|
+
}
|
|
130
|
+
if (code.startsWith('INVALID_') || code === 'VALIDATION_ERROR')
|
|
131
|
+
return 'refused';
|
|
132
|
+
// Неизвестный код: класс по exit. 2 — вход, 3 — нет записи, 4 — состояние;
|
|
133
|
+
// все три — проверенный отказ до записи. Иное (1, сигнал) — сбой backend:
|
|
134
|
+
// для мутации исход неизвестен.
|
|
135
|
+
if (exit === 2)
|
|
136
|
+
return 'refused';
|
|
137
|
+
if (exit === 3)
|
|
138
|
+
return 'not-found';
|
|
139
|
+
if (exit === 4)
|
|
140
|
+
return 'conflict';
|
|
141
|
+
return mutation ? 'uncertain' : 'unavailable';
|
|
142
|
+
}
|
package/lib/package.d.ts
ADDED
package/lib/package.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { type ContextSnapshot, type ContractDocument, type ExecutionPolicy } from '../contracts/index.ts';
|
|
3
|
+
import { type planCheckDataSchema, type planRequestDataSchema } from '../contracts/planning.ts';
|
|
4
|
+
export type PlanRequestData = z.infer<typeof planRequestDataSchema>;
|
|
5
|
+
export type PlanCheckData = z.infer<typeof planCheckDataSchema>;
|
|
6
|
+
export interface PlanInputs {
|
|
7
|
+
policy: ExecutionPolicy;
|
|
8
|
+
baseDir: string;
|
|
9
|
+
context?: ContextSnapshot;
|
|
10
|
+
contracts?: ContractDocument[];
|
|
11
|
+
}
|
|
12
|
+
/** `harness plan-request`: prompt, basis и факты; ничего не пишет. */
|
|
13
|
+
export declare function planRequestOf(input: PlanInputs & {
|
|
14
|
+
brief: string;
|
|
15
|
+
requirementSources?: {
|
|
16
|
+
repositoryId: string;
|
|
17
|
+
source: string;
|
|
18
|
+
}[];
|
|
19
|
+
}): PlanRequestData;
|
|
20
|
+
/** `harness plan-check`: issues и план подготовки проверок либо граф. */
|
|
21
|
+
export declare function planCheck(input: PlanInputs & {
|
|
22
|
+
draft: unknown;
|
|
23
|
+
graphId: string;
|
|
24
|
+
brief?: string;
|
|
25
|
+
basis?: string;
|
|
26
|
+
}): PlanCheckData;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { HarnessError, digestOf, idSchema, relativePathSchema, workGraphDigest, } from "../contracts/index.js";
|
|
2
|
+
import { planDraftSchema, } from "../contracts/planning.js";
|
|
3
|
+
import { validationIssues } from "../validate.js";
|
|
4
|
+
import { requirementSnapshot } from "../verification/requirements.js";
|
|
5
|
+
import { planningFactsOf } from "./facts.js";
|
|
6
|
+
import { draftToGraph } from "./graph.js";
|
|
7
|
+
import { checkGaps, draftIssues } from "./issues.js";
|
|
8
|
+
import { planningBasis, planningRequest } from "./request.js";
|
|
9
|
+
import { standaloneInstructions } from "./standalone.js";
|
|
10
|
+
const factsOf = (input) => planningFactsOf(input.policy, {
|
|
11
|
+
baseDir: input.baseDir,
|
|
12
|
+
...(input.context ? { context: input.context } : {}),
|
|
13
|
+
...(input.contracts ? { contracts: input.contracts } : {}),
|
|
14
|
+
});
|
|
15
|
+
/** Каталог репозитория из фактов (путь уже разрешён от каталога политики). */
|
|
16
|
+
const repositoryPath = (facts, repositoryId) => facts.repositories.find((r) => r.id === repositoryId)?.path;
|
|
17
|
+
/** `harness plan-request`: prompt, basis и факты; ничего не пишет. */
|
|
18
|
+
export function planRequestOf(input) {
|
|
19
|
+
const facts = factsOf(input);
|
|
20
|
+
const requirements = (input.requirementSources ?? []).map(({ repositoryId, source }, i) => {
|
|
21
|
+
const path = repositoryPath(facts, repositoryId);
|
|
22
|
+
if (path === undefined)
|
|
23
|
+
throw new HarnessError('INVALID_INPUT', `--requirements: репозиторий не объявлен в политике: ${repositoryId}`, [{ path: ['--requirements', i], message: repositoryId }]);
|
|
24
|
+
// Тот же разбор отказов, что у plan-check: путь — вход, Git — готовность.
|
|
25
|
+
const snapshot = snapshotOf(facts, repositoryId, source);
|
|
26
|
+
if (snapshot instanceof HarnessError)
|
|
27
|
+
throw new HarnessError(snapshot.code, `--requirements: ${snapshot.message}`, [
|
|
28
|
+
{ path: ['--requirements', i], message: source },
|
|
29
|
+
]);
|
|
30
|
+
// В факт — без sha: prompt зависит только от текста требований.
|
|
31
|
+
return { repositoryId, source, requirements: snapshot.requirements };
|
|
32
|
+
});
|
|
33
|
+
const request = planningRequest({
|
|
34
|
+
brief: input.brief,
|
|
35
|
+
facts,
|
|
36
|
+
hostInstructions: standaloneInstructions({ requirements }),
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
prompt: request.prompt,
|
|
40
|
+
readOnly: request.readOnly,
|
|
41
|
+
recommendedTasks: request.recommendedTasks,
|
|
42
|
+
maxTasks: request.maxTasks,
|
|
43
|
+
basis: request.basis,
|
|
44
|
+
facts,
|
|
45
|
+
draftSchema: 'plan-draft',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** `harness plan-check`: issues и план подготовки проверок либо граф. */
|
|
49
|
+
export function planCheck(input) {
|
|
50
|
+
// 1. Входы.
|
|
51
|
+
if (!idSchema.safeParse(input.graphId).success)
|
|
52
|
+
return refused([
|
|
53
|
+
{
|
|
54
|
+
code: 'INVALID_INPUT',
|
|
55
|
+
path: ['--draft'],
|
|
56
|
+
message: `ID графа из имени draft не проходит формат ID: ${input.graphId}`,
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
if (input.basis !== undefined && input.brief === undefined)
|
|
60
|
+
return refused([
|
|
61
|
+
{ code: 'INVALID_INPUT', path: ['--basis'], message: 'plan-check: --basis требует --brief' },
|
|
62
|
+
]);
|
|
63
|
+
// 2. Факты и basis постановки.
|
|
64
|
+
const facts = factsOf(input);
|
|
65
|
+
const basis = input.brief === undefined ? undefined : planningBasis(input.brief, facts);
|
|
66
|
+
if (input.basis !== undefined && input.basis !== basis)
|
|
67
|
+
return refused([
|
|
68
|
+
{
|
|
69
|
+
code: 'APPROVAL_STALE',
|
|
70
|
+
path: ['--basis'],
|
|
71
|
+
message: 'Постановка или факты проекта изменились после plan-request: составьте draft заново',
|
|
72
|
+
},
|
|
73
|
+
], [], basis);
|
|
74
|
+
// 3. Форма draft; лишние ключи (approved, status, …) z.object отбрасывает.
|
|
75
|
+
const parsed = planDraftSchema.safeParse(input.draft);
|
|
76
|
+
if (!parsed.success)
|
|
77
|
+
return refused(parsed.error.issues.map((i) => ({
|
|
78
|
+
code: 'INVALID_INPUT',
|
|
79
|
+
path: ['draft', ...i.path.map((p) => (typeof p === 'symbol' ? String(p) : p))],
|
|
80
|
+
message: i.message,
|
|
81
|
+
})), [], basis);
|
|
82
|
+
const draft = parsed.data;
|
|
83
|
+
// 4. Структура и ссылки на факты; недостающие проверки — план их подготовки, draft не меняется.
|
|
84
|
+
const checkPlan = checkGaps(draft, facts);
|
|
85
|
+
const structural = draftIssues(draft, { facts }).map(inDraft);
|
|
86
|
+
if (structural.length)
|
|
87
|
+
return refused(structural, checkPlan, basis);
|
|
88
|
+
// 5. Требования — из источника на HEAD, не выдумываются.
|
|
89
|
+
const stale = requirementsAtHead(draft, facts);
|
|
90
|
+
if (stale.length)
|
|
91
|
+
return refused(stale, checkPlan, basis);
|
|
92
|
+
// 6. Draft → WorkGraph.
|
|
93
|
+
const built = draftToGraph(draft, {
|
|
94
|
+
graphId: input.graphId,
|
|
95
|
+
facts,
|
|
96
|
+
source: {
|
|
97
|
+
connector: 'files',
|
|
98
|
+
ref: `work/${input.graphId}.json`,
|
|
99
|
+
revision: basis ?? digestOf(draft),
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
if (built.issues.length || !built.graph)
|
|
103
|
+
return refused(built.issues.length
|
|
104
|
+
? built.issues.map(inDraft)
|
|
105
|
+
: [{ code: 'INTERNAL', path: ['graph'], message: 'draftToGraph не вернул граф' }], checkPlan, basis);
|
|
106
|
+
const graph = built.graph;
|
|
107
|
+
// 7. Те же проверки, что у validate и run.
|
|
108
|
+
const invalid = validationIssues(graph, input.policy, input.context);
|
|
109
|
+
if (invalid.length)
|
|
110
|
+
return refused(invalid, checkPlan, basis);
|
|
111
|
+
// 8. Граф без согласования: дальше review-plan/approve/run.
|
|
112
|
+
return {
|
|
113
|
+
issues: [],
|
|
114
|
+
checkPlan: [],
|
|
115
|
+
graph,
|
|
116
|
+
graphDigest: workGraphDigest(graph),
|
|
117
|
+
...(basis === undefined ? {} : { basis }),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** Ответ с проблемами: графа нет; checkPlan — только рядом с issues. */
|
|
121
|
+
const refused = (issues, checkPlan = [], basis) => ({
|
|
122
|
+
issues,
|
|
123
|
+
checkPlan,
|
|
124
|
+
...(basis === undefined ? {} : { basis }),
|
|
125
|
+
});
|
|
126
|
+
/** Пути draft-проблем — от входа plan-check: `['draft', 'tasks', i, …]`; `['graph', …]` как есть. */
|
|
127
|
+
const inDraft = (issue) => issue.path[0] === 'graph' || issue.path[0] === 'draft'
|
|
128
|
+
? issue
|
|
129
|
+
: { ...issue, path: ['draft', ...issue.path] };
|
|
130
|
+
function requirementsAtHead(draft, facts) {
|
|
131
|
+
const issues = [];
|
|
132
|
+
const snapshots = new Map();
|
|
133
|
+
draft.tasks.forEach((task, i) => (task.requirements ?? []).forEach((link, k) => {
|
|
134
|
+
const at = ['draft', 'tasks', i, 'requirements', k];
|
|
135
|
+
const key = JSON.stringify([task.repositoryId, link.source]);
|
|
136
|
+
if (!snapshots.has(key))
|
|
137
|
+
snapshots.set(key, snapshotOf(facts, task.repositoryId, link.source));
|
|
138
|
+
const snapshot = snapshots.get(key);
|
|
139
|
+
if (snapshot instanceof HarnessError) {
|
|
140
|
+
issues.push({ code: snapshot.code, path: [...at, 'source'], message: snapshot.message });
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const found = snapshot.requirements.find((r) => r.id === link.id);
|
|
144
|
+
if (!found)
|
|
145
|
+
issues.push({
|
|
146
|
+
code: 'INVALID_INPUT',
|
|
147
|
+
path: [...at, 'id'],
|
|
148
|
+
message: `Требование ${link.id} не найдено в ${link.source} на HEAD: требования не выдумываются`,
|
|
149
|
+
});
|
|
150
|
+
else if (found.digest !== link.digest)
|
|
151
|
+
issues.push({
|
|
152
|
+
code: 'APPROVAL_STALE',
|
|
153
|
+
path: [...at, 'digest'],
|
|
154
|
+
message: `Требование ${link.id} изменилось в ${link.source}: постановка устарела`,
|
|
155
|
+
});
|
|
156
|
+
}));
|
|
157
|
+
return issues;
|
|
158
|
+
}
|
|
159
|
+
/** Снимок источника на HEAD; отказ снимка становится issue с его кодом. */
|
|
160
|
+
function snapshotOf(facts, repositoryId, source) {
|
|
161
|
+
const path = repositoryPath(facts, repositoryId);
|
|
162
|
+
if (path === undefined)
|
|
163
|
+
return new HarnessError('INVALID_INPUT', `Репозиторий не объявлен: ${repositoryId}`);
|
|
164
|
+
if (!relativePathSchema.safeParse(source).success)
|
|
165
|
+
return new HarnessError('INVALID_INPUT', `Источник требований — относительный путь внутри репозитория: ${source}`);
|
|
166
|
+
try {
|
|
167
|
+
return requirementSnapshot(path, source, 'HEAD');
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
if (error instanceof HarnessError)
|
|
171
|
+
return error;
|
|
172
|
+
return new HarnessError('NOT_READY', `Источник требований не читается на HEAD: ${source}: ${error instanceof Error ? error.message : String(error)}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ContextSnapshot, type ContractDocument, type ExecutionPolicy } from '../contracts/index.ts';
|
|
2
|
+
import type { PlanningFacts } from '../contracts/planning.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Факты планирования из политики самостоятельного проекта. Роли репозитория —
|
|
5
|
+
* роли политики, затем роли, объявленные только репозиторием; привязка каждой
|
|
6
|
+
* берётся через `roleBinding` (роль репозитория заменяет роль политики).
|
|
7
|
+
* Встроенных ролей нет: планировать можно только объявленными.
|
|
8
|
+
*/
|
|
9
|
+
export declare function planningFactsOf(policy: ExecutionPolicy, options: {
|
|
10
|
+
baseDir: string;
|
|
11
|
+
context?: ContextSnapshot;
|
|
12
|
+
contracts?: readonly ContractDocument[];
|
|
13
|
+
}): PlanningFacts;
|