deadbyte-mcp 0.8.10 → 0.10.0
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/CONTEXT.md +41 -0
- package/MANIFEST.SHA256 +386 -94
- package/R34-BASELINE.json +9 -0
- package/README.txt +141 -10
- package/bench/fixtures/corpus.json +36 -0
- package/bench/fixtures/r36/case-map.json +8 -0
- package/bin/WORKER-REGISTRY.txt +3 -3
- package/bin/appcontainer-stage.exe +0 -0
- package/bin/appcontainer-stage.obj +0 -0
- package/bin/bootstrap-advapi32.exe +0 -0
- package/bin/bootstrap-advapi32.obj +0 -0
- package/bin/bootstrap-exitcode.exe +0 -0
- package/bin/bootstrap-exitcode.obj +0 -0
- package/bin/bootstrap-kernel32.exe +0 -0
- package/bin/bootstrap-kernel32.obj +0 -0
- package/bin/child-control-probe.exe +0 -0
- package/bin/child-control-probe.obj +0 -0
- package/bin/child-control-stage.exe +0 -0
- package/bin/child-control-stage.obj +0 -0
- package/bin/contained-reverse-worker.exe +0 -0
- package/bin/contained-reverse-worker.obj +0 -0
- package/bin/contained-transform-worker.exe +0 -0
- package/bin/contained-transform-worker.obj +0 -0
- package/bin/containment-probe.exe +0 -0
- package/bin/containment-probe.obj +0 -0
- package/bin/deadbyte-contain.exe +0 -0
- package/bin/deadbyte-contain.obj +0 -0
- package/bin/deadbyte-exec.exe +0 -0
- package/bin/deadbyte-exec.obj +0 -0
- package/bin/deadbyte-process-host.exe +0 -0
- package/bin/deadbyte-process-host.obj +0 -0
- package/bin/deadbyte-tunnel-host.exe +0 -0
- package/bin/deadbyte-tunnel-host.obj +0 -0
- package/controller/README.TXT +12 -4
- package/controller/deadbyte-controller.config.psd1.example +14 -0
- package/controller/deadbyte-controller.ps1 +191 -20
- package/controller/deadbyte-process-policy.json +5 -5
- package/controller/deadbyte-semantic-lsp-config.json +95 -0
- package/docs/ADR-0001-PRODUCTION-BASELINE-SEAMS.md +29 -0
- package/docs/ARCHITECTURE.md +6 -5
- package/docs/R36-CAPABILITY-EVIDENCE.md +43 -0
- package/docs/superpowers/plans/2026-09-16-deadbyte-loop-engine.md +846 -0
- package/docs/superpowers/plans/2026-09-17-r35-production-successor.md +408 -0
- package/docs/superpowers/plans/2026-09-18-r36-zero-loss-autonomy.md +739 -0
- package/docs/superpowers/specs/2026-09-16-deadbyte-loop-engine-design.md +435 -0
- package/docs/superpowers/specs/2026-09-17-r35-production-successor-design.md +220 -0
- package/docs/superpowers/specs/2026-09-18-r36-zero-loss-autonomy-design.md +640 -0
- package/node_modules/typescript/LICENSE.txt +55 -0
- package/node_modules/typescript/README.md +50 -0
- package/node_modules/typescript/SECURITY.md +41 -0
- package/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
- package/node_modules/typescript/bin/tsc +2 -0
- package/node_modules/typescript/bin/tsserver +2 -0
- package/node_modules/typescript/lib/_tsc.js +133818 -0
- package/node_modules/typescript/lib/_tsserver.js +659 -0
- package/node_modules/typescript/lib/_typingsInstaller.js +222 -0
- package/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/lib.d.ts +22 -0
- package/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
- package/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
- package/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
- package/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
- package/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
- package/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
- package/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
- package/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
- package/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
- package/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
- package/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
- package/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
- package/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
- package/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
- package/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
- package/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
- package/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
- package/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
- package/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
- package/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
- package/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
- package/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
- package/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
- package/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
- package/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
- package/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
- package/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
- package/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
- package/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
- package/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
- package/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
- package/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
- package/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
- package/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
- package/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
- package/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
- package/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
- package/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
- package/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
- package/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
- package/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
- package/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
- package/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
- package/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
- package/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
- package/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
- package/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
- package/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
- package/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
- package/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
- package/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
- package/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
- package/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
- package/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
- package/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
- package/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
- package/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
- package/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
- package/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
- package/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
- package/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
- package/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
- package/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
- package/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
- package/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
- package/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
- package/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
- package/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
- package/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
- package/node_modules/typescript/lib/lib.es6.d.ts +23 -0
- package/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
- package/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
- package/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
- package/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
- package/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
- package/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
- package/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
- package/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
- package/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
- package/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
- package/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
- package/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
- package/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
- package/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
- package/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
- package/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
- package/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
- package/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/tsc.js +8 -0
- package/node_modules/typescript/lib/tsserver.js +8 -0
- package/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
- package/node_modules/typescript/lib/tsserverlibrary.js +21 -0
- package/node_modules/typescript/lib/typesMap.json +497 -0
- package/node_modules/typescript/lib/typescript.d.ts +11437 -0
- package/node_modules/typescript/lib/typescript.js +200276 -0
- package/node_modules/typescript/lib/typingsInstaller.js +8 -0
- package/node_modules/typescript/lib/watchGuard.js +53 -0
- package/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
- package/node_modules/typescript/package.json +120 -0
- package/package.json +5 -3
- package/proof/CONTAINMENT-BUILD.txt +6 -6
- package/proof/R34-TASK8-SUPERVISOR-CHECKPOINT.json +29 -0
- package/proof/R34-TASK9-MCP-SURFACE-CHECKPOINT.json +28 -0
- package/scripts/capability-benchmark.mjs +27 -0
- package/scripts/deferred-slot-operation.mjs +56 -16
- package/scripts/final-closure-verify.mjs +88 -39
- package/scripts/final-closure.mjs +63 -56
- package/scripts/gate-windows.ps1 +3 -3
- package/scripts/release-parity-tests.ps1 +9 -0
- package/scripts/release-parity.mjs +149 -139
- package/scripts/semantic-preflight.ps1 +73 -0
- package/scripts/tool-surface-snapshot.mjs +73 -0
- package/scripts/windows-gate-evidence.mjs +5 -5
- package/src/audit-verify.mjs +6 -2
- package/src/autonomous-action-reconcile.mjs +142 -0
- package/src/autonomous-context-engine.mjs +256 -0
- package/src/autonomous-live-state.mjs +17 -0
- package/src/autonomous-local-supervisor.mjs +249 -0
- package/src/autonomous-loop-state.mjs +304 -0
- package/src/autonomous-mcp-tools.mjs +5 -1
- package/src/autonomous-output-contracts.mjs +26 -7
- package/src/autonomous-plan.mjs +181 -0
- package/src/autonomous-planner-contracts.mjs +79 -0
- package/src/autonomous-planner.mjs +113 -6
- package/src/autonomous-policy.mjs +15 -2
- package/src/autonomous-progress.mjs +127 -0
- package/src/autonomous-runtime.mjs +785 -62
- package/src/autonomous-supervisor-host.mjs +70 -0
- package/src/autonomous-supervisor.mjs +31 -8
- package/src/capability-benchmark-runner.mjs +193 -0
- package/src/capability-benchmark.mjs +95 -0
- package/src/capability-ledger.mjs +158 -0
- package/src/coding-mcp-tools.mjs +65 -8
- package/src/coding-output-contracts.mjs +91 -8
- package/src/coding-plane.mjs +45 -9
- package/src/coding-search.mjs +130 -47
- package/src/compact-gateway-mcp-tools.mjs +128 -0
- package/src/compact-gateway-output-contracts.mjs +16 -0
- package/src/context-provenance.mjs +86 -0
- package/src/deadbyte-cli.mjs +145 -30
- package/src/document-adapter.mjs +43 -0
- package/src/lsp-stdio-client.mjs +112 -0
- package/src/machine-fs-smoke-client.mjs +2 -1
- package/src/machine-fs.mjs +51 -8
- package/src/mcp-server.mjs +46 -9
- package/src/native-diff-v2.mjs +337 -0
- package/src/native-diff.mjs +50 -2
- package/src/observation-smoke-client.mjs +3 -2
- package/src/operator-surface.mjs +43 -0
- package/src/process-runtime.mjs +98 -11
- package/src/process-smoke-client.mjs +11 -3
- package/src/provider-circuit.mjs +125 -0
- package/src/r36-compact-disarmed-probe.mjs +50 -0
- package/src/r36-full-surface-probe.mjs +56 -0
- package/src/release-generation.mjs +44 -5
- package/src/remote-live-log.mjs +76 -0
- package/src/remote-mcp-autonomous-smoke-client.mjs +58 -15
- package/src/remote-mcp-coding-smoke-client.mjs +5 -4
- package/src/remote-mcp-r24-disarmed-smoke-client.mjs +4 -2
- package/src/remote-mcp-r34-parity-client.mjs +177 -0
- package/src/remote-mcp-r36-parity-client.mjs +175 -0
- package/src/remote-mcp-smoke-client.mjs +113 -56
- package/src/remote-result-journal.mjs +114 -0
- package/src/runtime-update.mjs +109 -9
- package/src/search-cursor.mjs +45 -0
- package/src/semantic-backend-registry.mjs +39 -0
- package/src/semantic-code.mjs +246 -0
- package/src/semantic-lsp-backend.mjs +219 -0
- package/src/semantic-lsp-config.mjs +112 -0
- package/src/tool-surface-ledger.mjs +92 -0
- package/src/version.mjs +1 -1
- package/test/audit-verify.test.mjs +1 -1
- package/test/autonomous-action-reconcile.test.mjs +106 -0
- package/test/autonomous-adversarial.test.mjs +149 -6
- package/test/autonomous-capability-r36.test.mjs +151 -0
- package/test/autonomous-context-engine.test.mjs +181 -0
- package/test/autonomous-live-state.test.mjs +27 -0
- package/test/autonomous-local-supervisor.test.mjs +403 -0
- package/test/autonomous-loop-state.test.mjs +126 -0
- package/test/autonomous-loop-v2.test.mjs +105 -0
- package/test/autonomous-loop.test.mjs +79 -1
- package/test/autonomous-output-contract.test.mjs +54 -0
- package/test/autonomous-plan.test.mjs +101 -0
- package/test/autonomous-progress.test.mjs +106 -0
- package/test/autonomous-r34-e2e.test.mjs +338 -0
- package/test/autonomous-runtime.test.mjs +3 -3
- package/test/autonomous-supervisor-integration.test.mjs +48 -3
- package/test/capability-benchmark-r36.test.mjs +107 -0
- package/test/capability-benchmark-runner.test.mjs +49 -0
- package/test/capability-benchmark-semantic-r36.test.mjs +52 -0
- package/test/capability-benchmark.test.mjs +47 -0
- package/test/capability-claims-r36.test.mjs +23 -0
- package/test/capability-ledger-r36.test.mjs +102 -0
- package/test/cli-entrypoint.test.mjs +12 -0
- package/test/coding-catalog-consistency.test.mjs +24 -0
- package/test/coding-plane.test.mjs +3 -3
- package/test/coding-runtime.test.mjs +16 -0
- package/test/coding-search-r36.test.mjs +90 -0
- package/test/compact-catalog-r36.test.mjs +37 -0
- package/test/compact-gateway-r36.test.mjs +66 -0
- package/test/contained.test.mjs +1 -1
- package/test/context-provenance.test.mjs +61 -0
- package/test/controller-r27.test.mjs +4 -3
- package/test/controller.test.mjs +52 -0
- package/test/core.test.mjs +1 -1
- package/test/deferred-slot-operation-behavior.test.mjs +5 -1
- package/test/deferred-slot-operation.test.mjs +11 -1
- package/test/document-adapter.test.mjs +23 -0
- package/test/fixtures/lsp-framed-server.mjs +35 -0
- package/test/fixtures/semantic/cpp/compile_commands.json +4 -0
- package/test/fixtures/semantic/cpp/lib.cpp +2 -0
- package/test/fixtures/semantic/cpp/lib.hpp +2 -0
- package/test/fixtures/semantic/cpp/main.cpp +2 -0
- package/test/fixtures/semantic/python/lib.py +2 -0
- package/test/fixtures/semantic/python/main.py +2 -0
- package/test/fixtures/semantic/rust/Cargo.lock +7 -0
- package/test/fixtures/semantic/rust/Cargo.toml +8 -0
- package/test/fixtures/semantic/rust/src/lib.rs +3 -0
- package/test/fixtures/semantic/rust/src/main.rs +5 -0
- package/test/fixtures/semantic/rust/src/math.rs +3 -0
- package/test/fixtures/semantic/rust/target/.rustc_info.json +1 -0
- package/test/fixtures/semantic/rust/target/CACHEDIR.TAG +3 -0
- package/test/fixtures/semantic/rust/target/debug/.cargo-lock +0 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/dep-test-lib-semantic_rust +0 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/invoked.timestamp +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/test-lib-semantic_rust +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/test-lib-semantic_rust.json +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/dep-test-bin-semantic_rust_bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/invoked.timestamp +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/test-bin-semantic_rust_bin +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/test-bin-semantic_rust_bin.json +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/dep-lib-semantic_rust +0 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/invoked.timestamp +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/lib-semantic_rust +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/lib-semantic_rust.json +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/bin-semantic_rust_bin +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/bin-semantic_rust_bin.json +1 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/dep-bin-semantic_rust_bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/invoked.timestamp +1 -0
- package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust-4c168fa33c79d09c.rmeta +0 -0
- package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust-6212ccd976aa3808.rmeta +0 -0
- package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust_bin-5dcd474439c54a26.rmeta +0 -0
- package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust_bin-d741378dccdef61c.rmeta +0 -0
- package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust-4c168fa33c79d09c.d +5 -0
- package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust-6212ccd976aa3808.d +5 -0
- package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust_bin-5dcd474439c54a26.d +6 -0
- package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust_bin-d741378dccdef61c.d +6 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc-1qb77z00k06rqw4jdkj92spax/dep-graph.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc-1qb77z00k06rqw4jdkj92spax/query-cache.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc-1qb77z00k06rqw4jdkj92spax/work-products.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc.lock +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/dep-graph.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/metadata.rmeta +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/query-cache.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/work-products.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq.lock +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3-cmu3jai030no72y8u9eurrnjj/dep-graph.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3-cmu3jai030no72y8u9eurrnjj/query-cache.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3-cmu3jai030no72y8u9eurrnjj/work-products.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3.lock +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt-diy9mqvc2eoiblmhjs3stcgi3/dep-graph.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt-diy9mqvc2eoiblmhjs3stcgi3/query-cache.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt-diy9mqvc2eoiblmhjs3stcgi3/work-products.bin +0 -0
- package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt.lock +0 -0
- package/test/fixtures/semantic/rust/target/flycheck0/stderr +1 -0
- package/test/fixtures/semantic/rust/target/flycheck0/stdout +5 -0
- package/test/fixtures/semantic/typescript/lib.ts +3 -0
- package/test/fixtures/semantic/typescript/main.ts +2 -0
- package/test/fixtures/tool-surface-stdio-server.mjs +14 -0
- package/test/helpers/autonomous-r34-fixture.mjs +122 -0
- package/test/lsp-stdio-client.test.mjs +72 -0
- package/test/multi-file-read.test.mjs +44 -0
- package/test/native-diff-topology-r36.test.mjs +105 -0
- package/test/observation-integration.test.mjs +3 -3
- package/test/package-boundary.test.mjs +6 -0
- package/test/process-longrun-r36.test.mjs +82 -0
- package/test/process-release-gate.test.mjs +9 -0
- package/test/production-docs.test.mjs +48 -0
- package/test/prompts-resources.test.mjs +41 -0
- package/test/provider-circuit.test.mjs +93 -0
- package/test/public-autonomous-ingress-budget.test.mjs +28 -0
- package/test/r33-closeout-regression.test.mjs +4 -3
- package/test/r33-finalization.test.mjs +26 -18
- package/test/r36-finalization.test.mjs +104 -0
- package/test/r36-release-identity.test.mjs +52 -0
- package/test/release-generation.test.mjs +23 -2
- package/test/release-version.test.mjs +27 -17
- package/test/remote-live-log-r36.test.mjs +37 -0
- package/test/remote-live-log-recovery-r36.test.mjs +41 -0
- package/test/remote-r24-catalog.test.mjs +18 -4
- package/test/remote-result-journal.test.mjs +58 -0
- package/test/remote-session-cli.test.mjs +135 -30
- package/test/runtime-self-update.test.mjs +121 -1
- package/test/semantic-backend-registry.test.mjs +29 -0
- package/test/semantic-code.test.mjs +66 -0
- package/test/semantic-lsp-backend.test.mjs +108 -0
- package/test/semantic-lsp-config.test.mjs +81 -0
- package/test/semantic-lsp-readiness.test.mjs +34 -0
- package/test/semantic-lsp-transient-empty.test.mjs +32 -0
- package/test/semantic-lsp-transient-null.test.mjs +31 -0
- package/test/semantic-multilang.test.mjs +72 -0
- package/test/semantic-r36-rename.test.mjs +82 -0
- package/test/semantic-runtime-routing.test.mjs +32 -0
- package/test/semantic-server-config-integration.test.mjs +66 -0
- package/test/tool-surface-ledger.test.mjs +59 -0
- package/test/tool-surface-snapshot.test.mjs +17 -0
- package/test/tracer-bullet.test.mjs +77 -0
- package/deadbyte-mcp-0.8.9.tgz +0 -0
|
@@ -4,8 +4,14 @@ import path from 'node:path';
|
|
|
4
4
|
import { canonicalJson } from './canonical-json.mjs';
|
|
5
5
|
import { loadPrivateSigningKey, loadPublicVerifyKey } from './trust.mjs';
|
|
6
6
|
import { assertAutonomousArmed, autonomousSessionStatus } from './autonomous-policy.mjs';
|
|
7
|
-
import { buildPlannerPrompt, parsePlannerDecision, requestProviderDecision } from './autonomous-planner.mjs';
|
|
7
|
+
import { buildPlannerPrompt, parsePlannerDecision, parseR34PlannerDecision, requestProviderDecision } from './autonomous-planner.mjs';
|
|
8
|
+
import { actionIdentity, reconcileStartedAction } from './autonomous-action-reconcile.mjs';
|
|
9
|
+
import { createPlan, replanPlan, completePlanStep, planIsComplete as r34PlanIsComplete } from './autonomous-plan.mjs';
|
|
10
|
+
import { deriveLoopState, repairFingerprint } from './autonomous-loop-state.mjs';
|
|
11
|
+
import { judgeProgress, stallDisposition } from './autonomous-progress.mjs';
|
|
12
|
+
import { classifyProviderFailure, deriveCircuit, providerCallDisposition, providerCircuitId } from './provider-circuit.mjs';
|
|
8
13
|
import { verifyObservationReceiptFile } from './observation-runtime.mjs';
|
|
14
|
+
import { R36_CAPABILITY_LEDGER } from './capability-ledger.mjs';
|
|
9
15
|
|
|
10
16
|
export const AUTONOMOUS_GOAL_SCHEMA = 'deadbyte.autonomous-goal.v1';
|
|
11
17
|
export const AUTONOMOUS_EVENT_SCHEMA = 'deadbyte.autonomous-event.v1';
|
|
@@ -196,7 +202,8 @@ function profileOutcome(profile, checked) {
|
|
|
196
202
|
...(profile.kind === 'command' ? { exit_code:receipt.exit_code, timed_out:receipt.timed_out, elapsed_ms:receipt.elapsed_ms } :
|
|
197
203
|
{ median_ms:receipt.median_ms, p95_ms:receipt.p95_ms, regression_pct:receipt.regression_pct, verdict:receipt.verdict }) } };
|
|
198
204
|
}
|
|
199
|
-
async function executeProfile({ ctx, events, goalId, actionKey, profileId, epoch, policy, codingRuntime, signingKeyPath
|
|
205
|
+
async function executeProfile({ ctx, events, goalId, actionKey, profileId, epoch, policy, codingRuntime, signingKeyPath,
|
|
206
|
+
r34ResumePhase = null }) {
|
|
200
207
|
const profile = policy.profiles[profileId];
|
|
201
208
|
if (!profile) throw new Error(`autonomous profile '${profileId}' not found`);
|
|
202
209
|
const prior = [...events].reverse().find(event => event.type === 'profile_completed' && event.payload?.action_key === actionKey && event.payload?.profile_id === profileId);
|
|
@@ -204,14 +211,38 @@ async function executeProfile({ ctx, events, goalId, actionKey, profileId, epoch
|
|
|
204
211
|
const receiptId = profileReceiptId(goalId, actionKey, profileId);
|
|
205
212
|
const requestSha256 = profileRequestSha(codingRuntime, profile);
|
|
206
213
|
const started = [...events].reverse().find(event => event.type === 'profile_started' && event.payload?.action_key === actionKey && event.payload?.profile_id === profileId);
|
|
214
|
+
async function pauseR34Ambiguous(detail) {
|
|
215
|
+
if (!r34ResumePhase) return null;
|
|
216
|
+
if (!events.some(event => event.type === 'waiting_entered' && event.payload?.action_key === actionKey)) {
|
|
217
|
+
await appendEvent(ctx,events,signingKeyPath,'waiting_entered',{
|
|
218
|
+
reason:'ambiguous_interrupted_action',requires_approval:true,resume_phase:r34ResumePhase,
|
|
219
|
+
action_key:actionKey,profile_id:profileId,detail:truncated(detail,512)
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{
|
|
223
|
+
reason:'ambiguous_interrupted_action',action_key:actionKey,profile_id:profileId
|
|
224
|
+
});
|
|
225
|
+
return {status:'paused',reason:'ambiguous_interrupted_action',observation:null,existing:false};
|
|
226
|
+
}
|
|
207
227
|
if (started) {
|
|
208
228
|
const checked = await codingRuntime.verifyReceiptDetailed(receiptId);
|
|
209
229
|
if (!checked.ok) {
|
|
230
|
+
const r34Paused=await pauseR34Ambiguous(checked.reason ?? 'profile receipt verification failed');
|
|
231
|
+
if (r34Paused) return r34Paused;
|
|
210
232
|
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{ reason:'interrupted_profile_without_receipt', profile_id:profileId, action_key:actionKey });
|
|
211
233
|
return { status:'paused', observation:null, existing:false };
|
|
212
234
|
}
|
|
213
|
-
if (checked.request_sha256 !== requestSha256)
|
|
214
|
-
|
|
235
|
+
if (checked.request_sha256 !== requestSha256) {
|
|
236
|
+
const r34Paused=await pauseR34Ambiguous(`profile '${profileId}' recovered receipt request mismatch`);
|
|
237
|
+
if (r34Paused) return r34Paused;
|
|
238
|
+
throw new Error(`profile '${profileId}' recovered receipt request mismatch`);
|
|
239
|
+
}
|
|
240
|
+
const outcome = profileOutcome(profile,checked);
|
|
241
|
+
if (!outcome.valid) {
|
|
242
|
+
const r34Paused=await pauseR34Ambiguous(outcome.reason);
|
|
243
|
+
if (r34Paused) return r34Paused;
|
|
244
|
+
throw new Error(outcome.reason);
|
|
245
|
+
}
|
|
215
246
|
const payload = { action_key:actionKey, profile_id:profileId, mutation_epoch:epoch, passed:outcome.passed,
|
|
216
247
|
recovered:true, required_for_release:profile.required_for_release, run_after_mutation:profile.run_after_mutation, ...outcome.payload };
|
|
217
248
|
await appendEvent(ctx,events,signingKeyPath,'profile_completed',payload);
|
|
@@ -232,6 +263,8 @@ async function executeProfile({ ctx, events, goalId, actionKey, profileId, epoch
|
|
|
232
263
|
} catch (error) {
|
|
233
264
|
const checked = await codingRuntime.verifyReceiptDetailed(receiptId);
|
|
234
265
|
if (!checked.ok) {
|
|
266
|
+
const r34Paused=await pauseR34Ambiguous(checked.reason ?? error);
|
|
267
|
+
if (r34Paused) return r34Paused;
|
|
235
268
|
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{ reason:'profile_execution_without_receipt', profile_id:profileId,
|
|
236
269
|
action_key:actionKey, detail:truncated(error) });
|
|
237
270
|
return { status:'paused', observation:null, existing:false };
|
|
@@ -240,9 +273,16 @@ async function executeProfile({ ctx, events, goalId, actionKey, profileId, epoch
|
|
|
240
273
|
}
|
|
241
274
|
const checked = await codingRuntime.verifyReceiptDetailed(receiptId);
|
|
242
275
|
if (!checked.ok || checked.request_sha256 !== requestSha256 || (result && result.receipt_sha256 !== checked.receipt_sha256)) {
|
|
276
|
+
const r34Paused=await pauseR34Ambiguous(`profile '${profileId}' post-execution receipt verification failed`);
|
|
277
|
+
if (r34Paused) return r34Paused;
|
|
243
278
|
throw new Error(`profile '${profileId}' post-execution receipt verification failed`);
|
|
244
279
|
}
|
|
245
|
-
const outcome = profileOutcome(profile,checked);
|
|
280
|
+
const outcome = profileOutcome(profile,checked);
|
|
281
|
+
if (!outcome.valid) {
|
|
282
|
+
const r34Paused=await pauseR34Ambiguous(outcome.reason);
|
|
283
|
+
if (r34Paused) return r34Paused;
|
|
284
|
+
throw new Error(outcome.reason);
|
|
285
|
+
}
|
|
246
286
|
const payload = { action_key:actionKey, profile_id:profileId, mutation_epoch:epoch, passed:outcome.passed,
|
|
247
287
|
recovered:result === null, required_for_release:profile.required_for_release,
|
|
248
288
|
run_after_mutation:profile.run_after_mutation,
|
|
@@ -279,17 +319,38 @@ function normalizeGoal(policy, { submissionId, rootId, title = '', goal, accepta
|
|
|
279
319
|
return Object.freeze({ ...body, goal_sha256:sha256Object(body) });
|
|
280
320
|
}
|
|
281
321
|
|
|
282
|
-
|
|
322
|
+
function configuredCapabilityManifest({machineFsRuntime,observationRuntime,processRuntime,semanticRuntime}) {
|
|
323
|
+
const plannerReachable=id => id === 'coding.stat' || id === 'coding.search' || id === 'coding.files_read' ||
|
|
324
|
+
id.startsWith('semantic.') || id.startsWith('native_diff.') || id.startsWith('process.') ||
|
|
325
|
+
id.startsWith('machine_fs.') || id.startsWith('observation.') || id === 'autonomous.release_gate';
|
|
326
|
+
const runtimeEnabled=entry => {
|
|
327
|
+
if (entry.runtime_flag === 'DEADBYTE_CODING_RUNTIME' || entry.runtime_flag === 'DEADBYTE_AUTONOMOUS_RUNTIME') return true;
|
|
328
|
+
if (entry.runtime_flag === 'DEADBYTE_MACHINE_FS_RUNTIME') return Boolean(machineFsRuntime);
|
|
329
|
+
if (entry.runtime_flag === 'DEADBYTE_PROCESS_RUNTIME') return Boolean(processRuntime);
|
|
330
|
+
if (entry.runtime_flag === 'DEADBYTE_OBSERVATION_RUNTIME') return Boolean(observationRuntime);
|
|
331
|
+
return entry.runtime_flag === null;
|
|
332
|
+
};
|
|
333
|
+
const entries=R36_CAPABILITY_LEDGER.entries
|
|
334
|
+
.filter(entry=>entry.production && !entry.host_only && plannerReachable(entry.id) && runtimeEnabled(entry))
|
|
335
|
+
.filter(entry=>!entry.id.startsWith('semantic.') || Boolean(semanticRuntime))
|
|
336
|
+
.map(entry=>({id:entry.id,authority:entry.authority,mutating:entry.mutating,full_tool:entry.full_tool,
|
|
337
|
+
compact_tool:entry.compact_tool,compact_op:entry.compact_op}));
|
|
338
|
+
return Object.freeze({schema:'deadbyte.capability-manifest.v1',ledger_sha256:R36_CAPABILITY_LEDGER.ledger_sha256,
|
|
339
|
+
entries:Object.freeze(entries)});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async function plannerView(goal, state, codingRuntime, capabilityManifest) {
|
|
283
343
|
const tree = await codingRuntime.tree({ rootId:goal.root_id, path:'.', maxDepth:4, maxEntries:600 });
|
|
284
344
|
return { mutation_epoch:state.mutation_epoch, planner_round:state.planner_round, tree:tree.entries,
|
|
285
345
|
contexts:state.contexts.slice(-16), observations:state.observations.slice(-24), active_plan:state.active_plan,
|
|
346
|
+
capabilities:capabilityManifest,
|
|
286
347
|
recent_decisions:state.decisions.slice(-8).map(item => ({ planner_round:item.planner_round,
|
|
287
348
|
action:item.decision?.action, summary:item.decision?.summary })) };
|
|
288
349
|
}
|
|
289
350
|
function requestIdFor(goalId, plannerRound, journalHead) {
|
|
290
351
|
return sha256Object({ schema:'deadbyte.autonomous-planner-request.v1', goal_id:goalId, planner_round:plannerRound, journal_head_sha256:journalHead });
|
|
291
352
|
}
|
|
292
|
-
async function requestPlanner(ctx, goal, events, state, policy, codingRuntime, signingKeyPath) {
|
|
353
|
+
async function requestPlanner(ctx, goal, events, state, policy, codingRuntime, capabilityManifest, signingKeyPath) {
|
|
293
354
|
if (state.pending_request) return state.pending_request;
|
|
294
355
|
const round = state.planner_round + 1;
|
|
295
356
|
if (round > goal.max_iterations) {
|
|
@@ -300,7 +361,7 @@ async function requestPlanner(ctx, goal, events, state, policy, codingRuntime, s
|
|
|
300
361
|
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{ reason:'wall_time_limit', max_wall_ms:policy.limits.max_wall_ms });
|
|
301
362
|
return null;
|
|
302
363
|
}
|
|
303
|
-
const view = await plannerView(goal,state,codingRuntime);
|
|
364
|
+
const view = await plannerView(goal,state,codingRuntime,capabilityManifest);
|
|
304
365
|
let prompt = buildPlannerPrompt({ goal:{ title:goal.title, goal:goal.goal, acceptance:goal.acceptance }, policy, view });
|
|
305
366
|
const repair = [...(state.planner_rejections ?? [])].reverse().find(item => item.planner_round === round) ?? null;
|
|
306
367
|
if (repair) {
|
|
@@ -337,15 +398,117 @@ function validatePlanTransition(previous, next) {
|
|
|
337
398
|
function planIsComplete(plan) {
|
|
338
399
|
return Boolean(plan?.steps?.length) && plan.steps.every(step => step.status === 'completed');
|
|
339
400
|
}
|
|
340
|
-
|
|
401
|
+
function parseRuntimePlannerDecision(rawText,policy) {
|
|
402
|
+
let candidate;
|
|
403
|
+
try { candidate = JSON.parse(rawText); }
|
|
404
|
+
catch { return parsePlannerDecision(rawText,policy); }
|
|
405
|
+
return candidate?.schema === 'deadbyte.autonomous-decision.v2'
|
|
406
|
+
? parseR34PlannerDecision(rawText,policy)
|
|
407
|
+
: parsePlannerDecision(rawText,policy);
|
|
408
|
+
}
|
|
409
|
+
function hasR34Loop(events) {
|
|
410
|
+
return events.some(event => event.type === 'plan_created' || event.type === 'plan_replanned' ||
|
|
411
|
+
event.type === 'waiting_entered' || event.payload?.decision?.schema === 'deadbyte.autonomous-decision.v2');
|
|
412
|
+
}
|
|
413
|
+
function loopStateOrNull(goal,events) {
|
|
414
|
+
return hasR34Loop(events) ? deriveLoopState(goal,events) : null;
|
|
415
|
+
}
|
|
416
|
+
function legacyPublicLoopPhase(phase) {
|
|
417
|
+
return ({PLAN:'PLANNING',INSPECT:'INSPECTING',ACT:'ACTING',VERIFY:'VERIFYING',CRITIC:'REPLANNING',
|
|
418
|
+
REPAIR:'REPLANNING',RELEASE:'VERIFYING',WAITING:'WAITING',SUCCEEDED:'COMPLETE',FAILED:'WAITING'})[phase] ?? 'WAITING';
|
|
419
|
+
}
|
|
420
|
+
function publicLoopState(loop) {
|
|
421
|
+
if (!loop) return null;
|
|
422
|
+
const currentStep=loop.current_step ? {
|
|
423
|
+
step_id:loop.current_step.step_id,intent:loop.current_step.intent,status:loop.current_step.status
|
|
424
|
+
} : null;
|
|
425
|
+
const progress=loop.progress ? {
|
|
426
|
+
verdict:loop.progress.verdict,score:loop.progress.score,
|
|
427
|
+
reason_codes:[...(loop.progress.reason_codes ?? [])],fingerprint:loop.progress.fingerprint
|
|
428
|
+
} : null;
|
|
429
|
+
const actionKind=loop.pending_action?.action?.kind ?? loop.pending_action?.kind ?? null;
|
|
430
|
+
const pendingAction=loop.pending_action && actionKind ? {
|
|
431
|
+
action_id:loop.pending_action.action_id,request_sha256:loop.pending_action.request_sha256,kind:actionKind
|
|
432
|
+
} : null;
|
|
433
|
+
return {
|
|
434
|
+
schema:'deadbyte.autonomous-loop-state.v1',phase:legacyPublicLoopPhase(loop.phase),plan_id:loop.plan_id,plan_version:loop.plan_version,
|
|
435
|
+
current_step:currentStep,replan_count:loop.replan_count,progress,
|
|
436
|
+
pending_action:pendingAction,pending_approval:loop.pending_approval,wait_reason:loop.wait_reason
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function withLoopResult(goal,events,result) {
|
|
440
|
+
const loop=publicLoopState(loopStateOrNull(goal,events));
|
|
441
|
+
return loop ? {...result,loop} : result;
|
|
442
|
+
}
|
|
443
|
+
function providerCircuitSnapshot(policy,events,observedAtUtc=new Date().toISOString()) {
|
|
444
|
+
if (policy.planner.backend !== 'openai_compatible') return null;
|
|
445
|
+
return deriveCircuit(events,providerCircuitId(policy.planner),policy.planner.circuit,observedAtUtc);
|
|
446
|
+
}
|
|
447
|
+
async function enterProviderCircuitWait({ctx,events,goal,policy,signingKeyPath,reason,circuit}) {
|
|
448
|
+
const loop=deriveLoopState(goal,events);
|
|
449
|
+
if (loop.phase !== 'WAITING') {
|
|
450
|
+
await appendEvent(ctx,events,signingKeyPath,'waiting_entered',{
|
|
451
|
+
reason,requires_approval:false,resume_phase:loop.phase,
|
|
452
|
+
provider_id:providerCircuitId(policy.planner),circuit_state:circuit.state,
|
|
453
|
+
next_probe_at_utc:circuit.next_probe_at_utc
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{
|
|
457
|
+
reason,provider_id:providerCircuitId(policy.planner),circuit_state:circuit.state,
|
|
458
|
+
next_probe_at_utc:circuit.next_probe_at_utc
|
|
459
|
+
});
|
|
460
|
+
return {status:'paused',reason,circuit};
|
|
461
|
+
}
|
|
462
|
+
async function requestProviderWithCircuit({ctx,events,goal,policy,pending,signingKeyPath}) {
|
|
463
|
+
const providerId=providerCircuitId(policy.planner);
|
|
464
|
+
let circuit=providerCircuitSnapshot(policy,events);
|
|
465
|
+
let disposition=providerCallDisposition(circuit);
|
|
466
|
+
if (!disposition.allowed && disposition.reason==='half_open_probe_limit') {
|
|
467
|
+
await appendEvent(ctx,events,signingKeyPath,'provider_call_failed',{
|
|
468
|
+
provider_id:providerId,request_id:pending.request_id,failure_class:'transport',interrupted_probe:true
|
|
469
|
+
});
|
|
470
|
+
circuit=providerCircuitSnapshot(policy,events);
|
|
471
|
+
disposition=providerCallDisposition(circuit);
|
|
472
|
+
}
|
|
473
|
+
if (!disposition.allowed) {
|
|
474
|
+
const reason=disposition.reason==='circuit_unavailable'?'provider_circuit_unavailable':'provider_circuit_open';
|
|
475
|
+
return {waiting:await enterProviderCircuitWait({ctx,events,goal,policy,signingKeyPath,reason,circuit})};
|
|
476
|
+
}
|
|
477
|
+
if (disposition.probe) {
|
|
478
|
+
await appendEvent(ctx,events,signingKeyPath,'provider_probe_started',{
|
|
479
|
+
provider_id:providerId,request_id:pending.request_id
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
try {
|
|
483
|
+
const response=await requestProviderDecision(policy,pending.prompt);
|
|
484
|
+
await appendEvent(ctx,events,signingKeyPath,'provider_call_succeeded',{
|
|
485
|
+
provider_id:providerId,request_id:pending.request_id,probe:disposition.probe===true
|
|
486
|
+
});
|
|
487
|
+
return {response};
|
|
488
|
+
} catch (error) {
|
|
489
|
+
await appendEvent(ctx,events,signingKeyPath,'provider_call_failed',{
|
|
490
|
+
provider_id:providerId,request_id:pending.request_id,failure_class:classifyProviderFailure(error),
|
|
491
|
+
probe:disposition.probe===true
|
|
492
|
+
});
|
|
493
|
+
circuit=providerCircuitSnapshot(policy,events);
|
|
494
|
+
if (circuit.state==='OPEN'||circuit.state==='UNAVAILABLE') {
|
|
495
|
+
const reason=circuit.state==='UNAVAILABLE'?'provider_circuit_unavailable':'provider_circuit_open';
|
|
496
|
+
return {waiting:await enterProviderCircuitWait({ctx,events,goal,policy,signingKeyPath,reason,circuit})};
|
|
497
|
+
}
|
|
498
|
+
throw error;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
async function acceptPlannerDecision({ ctx, events, goal, state, policy, codingRuntime, capabilityManifest, signingKeyPath, plannerResponse }) {
|
|
341
502
|
let currentState = state;
|
|
342
|
-
let pending = currentState.pending_request ?? await requestPlanner(ctx,goal,events,currentState,policy,codingRuntime,signingKeyPath);
|
|
503
|
+
let pending = currentState.pending_request ?? await requestPlanner(ctx,goal,events,currentState,policy,codingRuntime,capabilityManifest,signingKeyPath);
|
|
343
504
|
if (!pending) return null;
|
|
344
505
|
let suppliedResponse = plannerResponse;
|
|
345
506
|
while (pending) {
|
|
346
507
|
let response;
|
|
347
508
|
if (policy.planner.backend === 'openai_compatible') {
|
|
348
|
-
|
|
509
|
+
const provider=await requestProviderWithCircuit({ctx,events,goal,policy,pending,signingKeyPath});
|
|
510
|
+
if (provider.waiting) return {needs_planner:false,rejected:false,paused:true,provider_waiting:true};
|
|
511
|
+
response=provider.response;
|
|
349
512
|
} else {
|
|
350
513
|
if (!suppliedResponse) return { needs_planner:true, request:pending };
|
|
351
514
|
if (suppliedResponse.request_id !== pending.request_id) throw new Error('planner response request_id mismatch');
|
|
@@ -357,8 +520,8 @@ async function acceptPlannerDecision({ ctx, events, goal, state, policy, codingR
|
|
|
357
520
|
}
|
|
358
521
|
let decision;
|
|
359
522
|
try {
|
|
360
|
-
decision =
|
|
361
|
-
validatePlanTransition(currentState.active_plan,decision.plan);
|
|
523
|
+
decision = parseRuntimePlannerDecision(response.raw_text,policy);
|
|
524
|
+
if (decision.schema !== 'deadbyte.autonomous-decision.v2') validatePlanTransition(currentState.active_plan,decision.plan);
|
|
362
525
|
} catch (error) {
|
|
363
526
|
const reason = truncated(error,512);
|
|
364
527
|
const attempt = 1 + events.filter(event => event.type === 'planner_rejected' &&
|
|
@@ -376,7 +539,7 @@ async function acceptPlannerDecision({ ctx, events, goal, state, policy, codingR
|
|
|
376
539
|
return { needs_planner:false, rejected:true, paused:true };
|
|
377
540
|
}
|
|
378
541
|
currentState = deriveState(goal,events);
|
|
379
|
-
pending = await requestPlanner(ctx,goal,events,currentState,policy,codingRuntime,signingKeyPath);
|
|
542
|
+
pending = await requestPlanner(ctx,goal,events,currentState,policy,codingRuntime,capabilityManifest,signingKeyPath);
|
|
380
543
|
if (!pending) return null;
|
|
381
544
|
if (policy.planner.backend === 'client_sampling') return { needs_planner:true, request:pending };
|
|
382
545
|
continue;
|
|
@@ -405,7 +568,9 @@ async function executeInspect({ ctx, events, goal, decisionEvent, decision, codi
|
|
|
405
568
|
const read = await codingRuntime.fileRead({ rootId:goal.root_id, relativePath:item.path, encoding:'utf8' });
|
|
406
569
|
const bytes = Buffer.byteLength(read.content,'utf8');
|
|
407
570
|
if (bytes > item.max_bytes) throw new Error(`planner inspect '${item.path}' exceeds requested max_bytes`);
|
|
408
|
-
contexts.push({ path:item.path, sha256:read.sha256, bytes:read.bytes, content:read.content
|
|
571
|
+
contexts.push({ path:item.path, sha256:read.sha256, bytes:read.bytes, content:read.content,
|
|
572
|
+
observed_at_utc:new Date().toISOString(), trust_class:'workspace_read',
|
|
573
|
+
relevance_epoch:Number.isInteger(decisionEvent.mutation_epoch) ? decisionEvent.mutation_epoch : 0 });
|
|
409
574
|
}
|
|
410
575
|
await appendEvent(ctx,events,signingKeyPath,'inspect_completed',{
|
|
411
576
|
decision_event_sha256:decisionEvent.event_sha256, contexts
|
|
@@ -414,6 +579,18 @@ async function executeInspect({ ctx, events, goal, decisionEvent, decision, codi
|
|
|
414
579
|
}
|
|
415
580
|
|
|
416
581
|
const DELEGATED_MUTATIONS = new Set(['process_start','process_action','process_terminate','observation_search_cancel']);
|
|
582
|
+
const CAPABILITY_BY_ACTION=Object.freeze({
|
|
583
|
+
search:'coding.search',stat:'coding.stat',multi_read:'coding.files_read',
|
|
584
|
+
semantic_outline:'semantic.outline',semantic_definition:'semantic.definition',semantic_references:'semantic.references',
|
|
585
|
+
semantic_diagnostics:'semantic.diagnostics',semantic_implementations:'semantic.implementations',semantic_rename_preview:'semantic.rename_preview',
|
|
586
|
+
native_diff_apply:'native_diff.apply',native_diff_verify:'native_diff.verify',
|
|
587
|
+
process_start:'process.start',process_read:'process.read',process_status:'process.status',process_list:'process.list',process_action:'process.action',process_terminate:'process.terminate',
|
|
588
|
+
machine_fs_stat:'machine_fs.stat',machine_fs_list:'machine_fs.list',machine_fs_read:'machine_fs.read',machine_fs_mkdir:'machine_fs.mkdir',machine_fs_move:'machine_fs.move',machine_fs_delete:'machine_fs.delete',
|
|
589
|
+
machine_stat:'machine_fs.stat',machine_list:'machine_fs.list',machine_read:'machine_fs.read',
|
|
590
|
+
observation_search_start:'observation.search_start',observation_search_status:'observation.search_status',observation_search_page:'observation.search_page',observation_search_cancel:'observation.search_cancel',
|
|
591
|
+
observation_process_list:'observation.process_list',observation_system_status:'observation.system_status'
|
|
592
|
+
});
|
|
593
|
+
function capabilityIdForOperation(operation){return CAPABILITY_BY_ACTION[operation?.kind]??null;}
|
|
417
594
|
function assertDelegatedIdentity(events, operation) {
|
|
418
595
|
if (['observation_search_status','observation_search_page','observation_search_cancel'].includes(operation.kind)) {
|
|
419
596
|
const owned = events.some(event => event.type === 'delegated_action_completed' &&
|
|
@@ -427,8 +604,45 @@ function assertDelegatedIdentity(events, operation) {
|
|
|
427
604
|
}
|
|
428
605
|
}
|
|
429
606
|
async function invokeDelegatedOperation(goal, operation, runtimes) {
|
|
430
|
-
const { machineFsRuntime, observationRuntime, processRuntime } = runtimes;
|
|
607
|
+
const { codingRuntime, semanticRuntime, nativeDiffRuntime, machineFsRuntime, observationRuntime, processRuntime } = runtimes;
|
|
431
608
|
switch (operation.kind) {
|
|
609
|
+
case 'stat':
|
|
610
|
+
return codingRuntime.stat({rootId:goal.root_id,relativePath:operation.path,hash:operation.hash});
|
|
611
|
+
case 'search':
|
|
612
|
+
return codingRuntime.search({rootId:goal.root_id,path:operation.path,pattern:operation.pattern,target:operation.target,mode:operation.mode,
|
|
613
|
+
caseSensitive:operation.case_sensitive,maxResults:operation.max_results,maxFileBytes:operation.max_file_bytes,
|
|
614
|
+
maxScanBytes:operation.max_scan_bytes,pageSize:operation.page_size,cursor:operation.cursor});
|
|
615
|
+
case 'multi_read':
|
|
616
|
+
return codingRuntime.filesRead({rootId:goal.root_id,files:operation.files,maxTotalBytes:operation.max_total_bytes});
|
|
617
|
+
case 'semantic_outline':
|
|
618
|
+
if (!semanticRuntime) throw new Error('semantic runtime unavailable');
|
|
619
|
+
return semanticRuntime.outline({rootId:goal.root_id,relativePath:operation.path,maxSymbols:operation.max_symbols});
|
|
620
|
+
case 'semantic_definition':
|
|
621
|
+
if (!semanticRuntime) throw new Error('semantic runtime unavailable');
|
|
622
|
+
return semanticRuntime.definition({rootId:goal.root_id,relativePath:operation.path,line:operation.line,column:operation.column,maxResults:operation.max_results});
|
|
623
|
+
case 'semantic_references':
|
|
624
|
+
if (!semanticRuntime) throw new Error('semantic runtime unavailable');
|
|
625
|
+
return semanticRuntime.references({rootId:goal.root_id,relativePath:operation.path,line:operation.line,column:operation.column,maxResults:operation.max_results});
|
|
626
|
+
case 'semantic_diagnostics':
|
|
627
|
+
if (!semanticRuntime) throw new Error('semantic runtime unavailable');
|
|
628
|
+
return semanticRuntime.diagnostics({rootId:goal.root_id,relativePath:operation.path,maxResults:operation.max_results});
|
|
629
|
+
case 'semantic_implementations':
|
|
630
|
+
if (!semanticRuntime) throw new Error('semantic runtime unavailable');
|
|
631
|
+
return semanticRuntime.implementations({rootId:goal.root_id,relativePath:operation.path,line:operation.line,column:operation.column,maxResults:operation.max_results});
|
|
632
|
+
case 'semantic_rename_preview':
|
|
633
|
+
if (!semanticRuntime) throw new Error('semantic runtime unavailable');
|
|
634
|
+
return semanticRuntime.renamePreview({rootId:goal.root_id,relativePath:operation.path,line:operation.line,column:operation.column,newName:operation.new_name});
|
|
635
|
+
case 'native_diff_verify':
|
|
636
|
+
return nativeDiffRuntime.verify({diffId:operation.diff_id});
|
|
637
|
+
case 'machine_fs_stat':
|
|
638
|
+
if (!machineFsRuntime) throw new Error('machine filesystem runtime unavailable');
|
|
639
|
+
return machineFsRuntime.stat({rootId:goal.root_id,relativePath:operation.path,hash:operation.hash});
|
|
640
|
+
case 'machine_fs_list':
|
|
641
|
+
if (!machineFsRuntime) throw new Error('machine filesystem runtime unavailable');
|
|
642
|
+
return machineFsRuntime.list({rootId:goal.root_id,relativePath:operation.path,cursor:operation.cursor,limit:operation.limit,hashFiles:operation.hash_files});
|
|
643
|
+
case 'machine_fs_read':
|
|
644
|
+
if (!machineFsRuntime) throw new Error('machine filesystem runtime unavailable');
|
|
645
|
+
return machineFsRuntime.read({rootId:goal.root_id,relativePath:operation.path,offset:operation.offset,maxBytes:operation.max_bytes,hashFile:operation.hash_file});
|
|
432
646
|
case 'machine_stat':
|
|
433
647
|
if (!machineFsRuntime) throw new Error('machine filesystem runtime unavailable');
|
|
434
648
|
return machineFsRuntime.stat({ rootId:goal.root_id, relativePath:operation.path, hash:operation.hash });
|
|
@@ -462,7 +676,7 @@ async function invokeDelegatedOperation(goal, operation, runtimes) {
|
|
|
462
676
|
return observationRuntime.systemStatus();
|
|
463
677
|
case 'process_start':
|
|
464
678
|
if (!processRuntime) throw new Error('process runtime unavailable');
|
|
465
|
-
return processRuntime.start({ profileId:operation.profile_id, rootId:goal.root_id, cwd:operation.cwd, args:[] });
|
|
679
|
+
return processRuntime.start({ profileId:operation.profile_id, rootId:goal.root_id, cwd:operation.cwd, args:operation.args??[] });
|
|
466
680
|
case 'process_read':
|
|
467
681
|
if (!processRuntime) throw new Error('process runtime unavailable');
|
|
468
682
|
return processRuntime.read({ sessionId:operation.session_id, offset:operation.offset, maxBytes:operation.max_bytes });
|
|
@@ -504,7 +718,9 @@ async function verifyDelegatedEvidence(operation, result, runtimes, verifyKeyPat
|
|
|
504
718
|
}
|
|
505
719
|
async function executeDelegate({ ctx, events, goal, decisionEvent, decision, policy, runtimes, assertRunAuthority,
|
|
506
720
|
signingKeyPath, verifyKeyPath }) {
|
|
507
|
-
const
|
|
721
|
+
const capabilityId=capabilityIdForOperation(decision.operation);
|
|
722
|
+
if(!capabilityId) throw new Error(`unsupported typed capability action '${String(decision.operation?.kind)}'`);
|
|
723
|
+
const actionKey = `capability-${decisionEvent.event_sha256}`;
|
|
508
724
|
const prior = [...events].reverse().find(event => event.type === 'delegated_action_completed' && event.payload?.action_key === actionKey);
|
|
509
725
|
if (prior) return { status:'completed', result:prior.payload.result, existing:true };
|
|
510
726
|
const started = [...events].reverse().find(event => event.type === 'delegated_action_started' && event.payload?.action_key === actionKey);
|
|
@@ -513,7 +729,7 @@ async function executeDelegate({ ctx, events, goal, decisionEvent, decision, pol
|
|
|
513
729
|
operation_kind:decision.operation.kind });
|
|
514
730
|
return { status:'paused' };
|
|
515
731
|
}
|
|
516
|
-
await appendEvent(ctx,events,signingKeyPath,'delegated_action_started',{ action_key:actionKey,
|
|
732
|
+
await appendEvent(ctx,events,signingKeyPath,'delegated_action_started',{ action_key:actionKey, capability_id:capabilityId,
|
|
517
733
|
decision_event_sha256:decisionEvent.event_sha256, operation:decision.operation });
|
|
518
734
|
try {
|
|
519
735
|
assertDelegatedIdentity(events,decision.operation);
|
|
@@ -523,7 +739,7 @@ async function executeDelegate({ ctx, events, goal, decisionEvent, decision, pol
|
|
|
523
739
|
throw new Error('delegated result exceeds autonomous context bound');
|
|
524
740
|
}
|
|
525
741
|
const evidence = await verifyDelegatedEvidence(decision.operation,result,runtimes,verifyKeyPath);
|
|
526
|
-
await appendEvent(ctx,events,signingKeyPath,'delegated_action_completed',{ action_key:actionKey,
|
|
742
|
+
await appendEvent(ctx,events,signingKeyPath,'delegated_action_completed',{ action_key:actionKey, capability_id:capabilityId,
|
|
527
743
|
decision_event_sha256:decisionEvent.event_sha256, operation:decision.operation, result, evidence });
|
|
528
744
|
return { status:'completed', result, evidence };
|
|
529
745
|
} catch (error) {
|
|
@@ -546,34 +762,209 @@ async function runMutationProfiles({ ctx, events, goal, epoch, actionKey, policy
|
|
|
546
762
|
}
|
|
547
763
|
return results;
|
|
548
764
|
}
|
|
765
|
+
function patchActionCoordinates(state) {
|
|
766
|
+
const plan = state.active_plan ?? null;
|
|
767
|
+
const planId = SHA256_RE.test(plan?.plan_id ?? '')
|
|
768
|
+
? plan.plan_id
|
|
769
|
+
: sha256Object({ schema:'deadbyte.autonomous-plan-coordinate.v1', plan });
|
|
770
|
+
const planVersion = Number.isInteger(plan?.plan_version) && plan.plan_version >= 1
|
|
771
|
+
? plan.plan_version
|
|
772
|
+
: Math.max(1,Number(state.planner_round) || 1);
|
|
773
|
+
const activeStep = plan?.steps?.find(step => ['active','running','failed'].includes(step.status))
|
|
774
|
+
?? plan?.steps?.find(step => step.status === 'pending')
|
|
775
|
+
?? null;
|
|
776
|
+
const stepId = ID_RE.test(activeStep?.step_id ?? '')
|
|
777
|
+
? activeStep.step_id
|
|
778
|
+
: `decision-${Math.max(1,Number(state.planner_round) || 1)}`;
|
|
779
|
+
return { planId,planVersion,stepId };
|
|
780
|
+
}
|
|
781
|
+
function patchStartedForDecision(events, decisionEventSha) {
|
|
782
|
+
return [...events].reverse().find(event => event.type === 'action_started' &&
|
|
783
|
+
event.payload?.decision_event_sha256 === decisionEventSha && event.payload?.action?.kind === 'patch') ?? null;
|
|
784
|
+
}
|
|
785
|
+
function patchCommitForAction(events, actionId) {
|
|
786
|
+
return [...events].reverse().find(event => event.type === 'native_diff_committed' &&
|
|
787
|
+
event.payload?.action_id === actionId) ?? null;
|
|
788
|
+
}
|
|
789
|
+
function patchCompletionForAction(events, actionId) {
|
|
790
|
+
return [...events].reverse().find(event => event.type === 'action_completed' &&
|
|
791
|
+
event.payload?.action_id === actionId) ?? null;
|
|
792
|
+
}
|
|
793
|
+
async function verifyPatchDiff(nativeDiffRuntime,diffId) {
|
|
794
|
+
const verified = await nativeDiffRuntime.verify({ diffId });
|
|
795
|
+
if (!verified.ok || verified.current_state_matches !== true) {
|
|
796
|
+
throw new Error(`autonomous native diff verification failed: ${verified.reason ?? 'state mismatch'}`);
|
|
797
|
+
}
|
|
798
|
+
return verified;
|
|
799
|
+
}
|
|
800
|
+
async function appendPatchCommit({ctx,events,signingKeyPath,started,decisionEvent,verified,recovered=false}) {
|
|
801
|
+
const actionId = started.payload.action_id;
|
|
802
|
+
const prior = patchCommitForAction(events,actionId);
|
|
803
|
+
if (prior) return prior;
|
|
804
|
+
const action = started.payload.action;
|
|
805
|
+
const verifiedPaths=[...new Set((verified.final_states??[]).flatMap(item=>[
|
|
806
|
+
typeof item?.path==='string'?item.path:null,
|
|
807
|
+
typeof item?.source_path==='string'?item.source_path:null,
|
|
808
|
+
typeof item?.destination_path==='string'?item.destination_path:null
|
|
809
|
+
].filter(Boolean)))].sort((a,b)=>a.localeCompare(b,'en'));
|
|
810
|
+
return appendEvent(ctx,events,signingKeyPath,'native_diff_committed',{
|
|
811
|
+
action_id:actionId, decision_event_sha256:decisionEvent.event_sha256, diff_id:action.diff_id,
|
|
812
|
+
diff_receipt_sha256:verified.receipt_sha256, mutation_epoch:started.payload.target_mutation_epoch,
|
|
813
|
+
mutation_count:started.payload.mutation_count, operation_count:action.operation_count,
|
|
814
|
+
paths:Array.isArray(action.paths)&&action.paths.length>0?action.paths:verifiedPaths,
|
|
815
|
+
coding_receipts_verified:verified.coding_receipts_verified,
|
|
816
|
+
...(recovered ? { recovered:true } : {})
|
|
817
|
+
});
|
|
818
|
+
}
|
|
549
819
|
async function executePatch({ ctx, events, goal, state, decisionEvent, decision, nativeDiffRuntime,
|
|
550
|
-
policy, codingRuntime, signingKeyPath }) {
|
|
551
|
-
|
|
820
|
+
policy, codingRuntime, signingKeyPath, actionCoordinatesOverride = null }) {
|
|
821
|
+
let started = patchStartedForDecision(events,decisionEvent.event_sha256);
|
|
822
|
+
if (!started && state.mutation_count + decision.operations.length > policy.limits.max_mutations) {
|
|
552
823
|
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{
|
|
553
824
|
reason:'mutation_limit', max_mutations:policy.limits.max_mutations
|
|
554
825
|
});
|
|
555
826
|
return { status:'paused' };
|
|
556
827
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
828
|
+
|
|
829
|
+
if (!started) {
|
|
830
|
+
const applicationScope = sha256Object({ schema:'deadbyte.autonomous-native-diff-scope.v1',
|
|
831
|
+
goal_id:goal.goal_id, decision_event_sha256:decisionEvent.event_sha256 });
|
|
832
|
+
const preview = await nativeDiffRuntime.preview({ rootId:goal.root_id,
|
|
833
|
+
operations:decision.operations, title:decision.summary, applicationScope });
|
|
834
|
+
const coordinates = actionCoordinatesOverride ?? patchActionCoordinates(state);
|
|
835
|
+
const action = { kind:'patch', diff_id:preview.diff_id,
|
|
836
|
+
operation_count:preview.operation_count, paths:preview.paths };
|
|
837
|
+
const identity = actionIdentity({ goalId:goal.goal_id, planId:coordinates.planId,
|
|
838
|
+
planVersion:coordinates.planVersion, stepId:coordinates.stepId, mutationEpoch:state.mutation_epoch,
|
|
839
|
+
decisionEventSha:decisionEvent.event_sha256, action });
|
|
840
|
+
started = await appendEvent(ctx,events,signingKeyPath,'action_started',{
|
|
841
|
+
...identity, decision_event_sha256:decisionEvent.event_sha256,
|
|
842
|
+
plan_id:coordinates.planId, plan_version:coordinates.planVersion, step_id:coordinates.stepId,
|
|
843
|
+
mutation_epoch:state.mutation_epoch, target_mutation_epoch:state.mutation_epoch + 1,
|
|
844
|
+
mutation_count:decision.operations.length, action
|
|
845
|
+
});
|
|
565
846
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
847
|
+
|
|
848
|
+
const actionId = started.payload.action_id;
|
|
849
|
+
const diffId = started.payload.action.diff_id;
|
|
850
|
+
const existingCompletion = patchCompletionForAction(events,actionId);
|
|
851
|
+
if (existingCompletion) {
|
|
852
|
+
const committed = patchCommitForAction(events,actionId);
|
|
853
|
+
if (!committed) throw new Error('completed patch action missing native diff commit');
|
|
854
|
+
const epoch = committed.payload.mutation_epoch;
|
|
855
|
+
const profiles = await runMutationProfiles({ ctx,events,goal,epoch,
|
|
856
|
+
actionKey:`mutation-${epoch}`,policy,codingRuntime,signingKeyPath });
|
|
857
|
+
return { status:profiles.some(item => item.status === 'paused') ? 'paused' : 'completed',
|
|
858
|
+
diff_id:diffId, mutation_epoch:epoch, profiles, recovered:true };
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
const reconciliation = await reconcileStartedAction({ startedEvent:started, journal:events,
|
|
862
|
+
runtimes:{ nativeDiffRuntime,codingRuntime } });
|
|
863
|
+
if (reconciliation.classification === 'ambiguous') {
|
|
864
|
+
if (!events.some(event => event.type === 'waiting_entered' && event.payload?.action_id === actionId)) {
|
|
865
|
+
await appendEvent(ctx,events,signingKeyPath,'waiting_entered',{
|
|
866
|
+
reason:'ambiguous_interrupted_action', action_id:actionId,
|
|
867
|
+
decision_event_sha256:decisionEvent.event_sha256, detail:truncated(reconciliation.reason,512)
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{
|
|
871
|
+
reason:'ambiguous_interrupted_action', action_id:actionId,
|
|
872
|
+
decision_event_sha256:decisionEvent.event_sha256
|
|
873
|
+
});
|
|
874
|
+
return { status:'paused', reason:'ambiguous_interrupted_action' };
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
let verified;
|
|
878
|
+
let recovered = false;
|
|
879
|
+
if (reconciliation.classification === 'executed_verified') {
|
|
880
|
+
recovered = true;
|
|
881
|
+
verified = await verifyPatchDiff(nativeDiffRuntime,diffId);
|
|
882
|
+
if (!events.some(event => event.type === 'action_reconciled' && event.payload?.action_id === actionId)) {
|
|
883
|
+
await appendEvent(ctx,events,signingKeyPath,'action_reconciled',{
|
|
884
|
+
action_id:actionId, request_sha256:started.payload.request_sha256,
|
|
885
|
+
decision_event_sha256:decisionEvent.event_sha256,
|
|
886
|
+
classification:reconciliation.classification, evidence:reconciliation.evidence
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
} else {
|
|
890
|
+
await nativeDiffRuntime.apply({ diffId });
|
|
891
|
+
verified = await verifyPatchDiff(nativeDiffRuntime,diffId);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
const committed = await appendPatchCommit({ctx,events,signingKeyPath,started,decisionEvent,verified,recovered});
|
|
895
|
+
if (!patchCompletionForAction(events,actionId)) {
|
|
896
|
+
await appendEvent(ctx,events,signingKeyPath,'action_completed',{
|
|
897
|
+
action_id:actionId, request_sha256:started.payload.request_sha256,
|
|
898
|
+
decision_event_sha256:decisionEvent.event_sha256, classification:'executed_verified',
|
|
899
|
+
diff_id:diffId, receipt_sha256:verified.receipt_sha256, recovered
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
const epoch = committed.payload.mutation_epoch;
|
|
573
903
|
const profiles = await runMutationProfiles({ ctx,events,goal,epoch,
|
|
574
904
|
actionKey:`mutation-${epoch}`,policy,codingRuntime,signingKeyPath });
|
|
575
905
|
return { status:profiles.some(item => item.status === 'paused') ? 'paused' : 'completed',
|
|
576
|
-
diff_id:
|
|
906
|
+
diff_id:diffId, mutation_epoch:epoch, profiles, recovered };
|
|
907
|
+
}
|
|
908
|
+
async function executePreparedDiff({ctx,events,goal,state,decisionEvent,diffId,expectedOperationCount,
|
|
909
|
+
policy,codingRuntime,nativeDiffRuntime,signingKeyPath}) {
|
|
910
|
+
let started=patchStartedForDecision(events,decisionEvent.event_sha256);
|
|
911
|
+
if(!started&&state.mutation_count+expectedOperationCount>policy.limits.max_mutations){
|
|
912
|
+
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{reason:'mutation_limit',max_mutations:policy.limits.max_mutations});
|
|
913
|
+
return {status:'paused'};
|
|
914
|
+
}
|
|
915
|
+
if(!started){
|
|
916
|
+
const coordinates=patchActionCoordinates(state);
|
|
917
|
+
const action={kind:'patch',diff_id:diffId,operation_count:expectedOperationCount,paths:[]};
|
|
918
|
+
const identity=actionIdentity({goalId:goal.goal_id,planId:coordinates.planId,planVersion:coordinates.planVersion,
|
|
919
|
+
stepId:coordinates.stepId,mutationEpoch:state.mutation_epoch,decisionEventSha:decisionEvent.event_sha256,action});
|
|
920
|
+
started=await appendEvent(ctx,events,signingKeyPath,'action_started',{
|
|
921
|
+
...identity,decision_event_sha256:decisionEvent.event_sha256,plan_id:coordinates.planId,
|
|
922
|
+
plan_version:coordinates.planVersion,step_id:coordinates.stepId,mutation_epoch:state.mutation_epoch,
|
|
923
|
+
target_mutation_epoch:state.mutation_epoch+1,mutation_count:expectedOperationCount,action
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
const actionId=started.payload.action_id;
|
|
927
|
+
const existingCompletion=patchCompletionForAction(events,actionId);
|
|
928
|
+
if(existingCompletion){
|
|
929
|
+
const committed=patchCommitForAction(events,actionId);
|
|
930
|
+
if(!committed) throw new Error('completed prepared diff action missing native diff commit');
|
|
931
|
+
const epoch=committed.payload.mutation_epoch;
|
|
932
|
+
const profiles=await runMutationProfiles({ctx,events,goal,epoch,actionKey:`mutation-${epoch}`,policy,codingRuntime,signingKeyPath});
|
|
933
|
+
return {status:profiles.some(item=>item.status==='paused')?'paused':'completed',diff_id:diffId,mutation_epoch:epoch,profiles,recovered:true};
|
|
934
|
+
}
|
|
935
|
+
const reconciliation=await reconcileStartedAction({startedEvent:started,journal:events,runtimes:{nativeDiffRuntime,codingRuntime}});
|
|
936
|
+
if(reconciliation.classification==='ambiguous'){
|
|
937
|
+
if(!events.some(event=>event.type==='waiting_entered'&&event.payload?.action_id===actionId)){
|
|
938
|
+
await appendEvent(ctx,events,signingKeyPath,'waiting_entered',{reason:'ambiguous_interrupted_action',action_id:actionId,
|
|
939
|
+
decision_event_sha256:decisionEvent.event_sha256,detail:truncated(reconciliation.reason,512)});
|
|
940
|
+
}
|
|
941
|
+
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{reason:'ambiguous_interrupted_action',action_id:actionId,
|
|
942
|
+
decision_event_sha256:decisionEvent.event_sha256});
|
|
943
|
+
return {status:'paused',reason:'ambiguous_interrupted_action'};
|
|
944
|
+
}
|
|
945
|
+
let verified; let recovered=false;
|
|
946
|
+
if(reconciliation.classification==='executed_verified'){
|
|
947
|
+
recovered=true;
|
|
948
|
+
verified=await verifyPatchDiff(nativeDiffRuntime,diffId);
|
|
949
|
+
if(verified.operation_count!==expectedOperationCount) throw new Error(`prepared native diff operation count mismatch: expected ${expectedOperationCount}, verified ${verified.operation_count}`);
|
|
950
|
+
if(!events.some(event=>event.type==='action_reconciled'&&event.payload?.action_id===actionId)){
|
|
951
|
+
await appendEvent(ctx,events,signingKeyPath,'action_reconciled',{action_id:actionId,request_sha256:started.payload.request_sha256,
|
|
952
|
+
decision_event_sha256:decisionEvent.event_sha256,classification:reconciliation.classification,evidence:reconciliation.evidence});
|
|
953
|
+
}
|
|
954
|
+
}else{
|
|
955
|
+
await nativeDiffRuntime.apply({diffId,expectedOperationCount});
|
|
956
|
+
verified=await verifyPatchDiff(nativeDiffRuntime,diffId);
|
|
957
|
+
if(verified.operation_count!==expectedOperationCount) throw new Error(`prepared native diff operation count mismatch: expected ${expectedOperationCount}, verified ${verified.operation_count}`);
|
|
958
|
+
}
|
|
959
|
+
const committed=await appendPatchCommit({ctx,events,signingKeyPath,started,decisionEvent,verified,recovered});
|
|
960
|
+
if(!patchCompletionForAction(events,actionId)){
|
|
961
|
+
await appendEvent(ctx,events,signingKeyPath,'action_completed',{action_id:actionId,request_sha256:started.payload.request_sha256,
|
|
962
|
+
decision_event_sha256:decisionEvent.event_sha256,classification:'executed_verified',diff_id:diffId,
|
|
963
|
+
receipt_sha256:verified.receipt_sha256,recovered});
|
|
964
|
+
}
|
|
965
|
+
const epoch=committed.payload.mutation_epoch;
|
|
966
|
+
const profiles=await runMutationProfiles({ctx,events,goal,epoch,actionKey:`mutation-${epoch}`,policy,codingRuntime,signingKeyPath});
|
|
967
|
+
return {status:profiles.some(item=>item.status==='paused')?'paused':'completed',diff_id:diffId,mutation_epoch:epoch,profiles,recovered};
|
|
577
968
|
}
|
|
578
969
|
async function runRequiredReleaseProfiles({ ctx, events, goal, state, policy, codingRuntime, signingKeyPath }) {
|
|
579
970
|
const requiredIds = Object.entries(policy.profiles)
|
|
@@ -696,10 +1087,280 @@ async function verifyReleaseReceipt({ ctx, goal, events, policy, verifyKeyPath,
|
|
|
696
1087
|
journal_head_sha256:completion.event_sha256 };
|
|
697
1088
|
}
|
|
698
1089
|
|
|
1090
|
+
function r34CompletedSteps(plan) {
|
|
1091
|
+
return Array.isArray(plan?.steps) ? plan.steps.filter(step => step.status === 'completed').length : 0;
|
|
1092
|
+
}
|
|
1093
|
+
function r34ProgressHistory(events) {
|
|
1094
|
+
const history=[];
|
|
1095
|
+
for (const event of events) {
|
|
1096
|
+
if (event.type === 'plan_replanned') history.push('replan');
|
|
1097
|
+
if (event.type === 'progress_judged' && ['progress','stalled','regressed'].includes(event.payload?.verdict)) {
|
|
1098
|
+
history.push(event.payload.verdict);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
return history;
|
|
1102
|
+
}
|
|
1103
|
+
async function r34PhaseChange({ctx,events,goal,signingKeyPath,to,reason}) {
|
|
1104
|
+
const loop=deriveLoopState(goal,events);
|
|
1105
|
+
if (loop.phase === to) return loop;
|
|
1106
|
+
await appendEvent(ctx,events,signingKeyPath,'phase_changed',{from:loop.phase,to,reason});
|
|
1107
|
+
return deriveLoopState(goal,events);
|
|
1108
|
+
}
|
|
1109
|
+
async function r35EnterCritic({ctx,events,goal,signingKeyPath,failureClass,evidenceFingerprint,detail}) {
|
|
1110
|
+
let loop=deriveLoopState(goal,events);
|
|
1111
|
+
const fingerprint=SHA256_RE.test(evidenceFingerprint ?? '') ? evidenceFingerprint : sha256Object({
|
|
1112
|
+
schema:'deadbyte.autonomous-critic-evidence.v1',failure_class:failureClass,detail:String(detail ?? '')
|
|
1113
|
+
});
|
|
1114
|
+
await appendEvent(ctx,events,signingKeyPath,'critic_classified',{
|
|
1115
|
+
failure_class:failureClass,evidence_fingerprint:fingerprint,detail:truncated(detail ?? failureClass,1024)
|
|
1116
|
+
});
|
|
1117
|
+
loop=deriveLoopState(goal,events);
|
|
1118
|
+
if (loop.phase !== 'CRITIC') loop=await r34PhaseChange({ctx,events,goal,signingKeyPath,to:'CRITIC',reason:failureClass});
|
|
1119
|
+
return loop;
|
|
1120
|
+
}
|
|
1121
|
+
async function r35BeginRepair({ctx,events,goal,signingKeyPath,hypothesis}) {
|
|
1122
|
+
let loop=deriveLoopState(goal,events);
|
|
1123
|
+
if (loop.phase !== 'CRITIC' && loop.phase !== 'REPAIR') throw new Error(`R35 repair requires CRITIC/REPAIR phase, got ${loop.phase}`);
|
|
1124
|
+
if (loop.phase === 'CRITIC') loop=await r34PhaseChange({ctx,events,goal,signingKeyPath,to:'REPAIR',reason:'critic_ready'});
|
|
1125
|
+
const priorHypothesis=loop.critic?.detail ?? hypothesis;
|
|
1126
|
+
const previousFingerprint=repairFingerprint({plan:loop.plan,hypothesis:priorHypothesis});
|
|
1127
|
+
await appendEvent(ctx,events,signingKeyPath,'repair_started',{
|
|
1128
|
+
previous_fingerprint:previousFingerprint,hypothesis:priorHypothesis
|
|
1129
|
+
});
|
|
1130
|
+
return {loop:deriveLoopState(goal,events),previousFingerprint};
|
|
1131
|
+
}
|
|
1132
|
+
async function r35CompleteRepair({ctx,events,goal,signingKeyPath,previousFingerprint,hypothesis}) {
|
|
1133
|
+
const loop=deriveLoopState(goal,events);
|
|
1134
|
+
const nextFingerprint=repairFingerprint({plan:loop.plan,hypothesis});
|
|
1135
|
+
await appendEvent(ctx,events,signingKeyPath,'repair_completed',{
|
|
1136
|
+
previous_fingerprint:previousFingerprint,repair_fingerprint:nextFingerprint,hypothesis
|
|
1137
|
+
});
|
|
1138
|
+
return deriveLoopState(goal,events);
|
|
1139
|
+
}
|
|
1140
|
+
async function r34EnterWaiting({ctx,events,goal,signingKeyPath,reason,resumePhase}) {
|
|
1141
|
+
const loop=deriveLoopState(goal,events);
|
|
1142
|
+
if (loop.phase !== 'WAITING') {
|
|
1143
|
+
await appendEvent(ctx,events,signingKeyPath,'waiting_entered',{
|
|
1144
|
+
reason,requires_approval:true,resume_phase:resumePhase ?? loop.phase
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{reason});
|
|
1148
|
+
return {status:'paused',reason};
|
|
1149
|
+
}
|
|
1150
|
+
function r34ReasonHash(goal,decisionEvent,reason) {
|
|
1151
|
+
return sha256Object({schema:'deadbyte.autonomous-plan-reason.v1',goal_id:goal.goal_id,
|
|
1152
|
+
decision_event_sha256:decisionEvent.event_sha256,reason:String(reason ?? '')});
|
|
1153
|
+
}
|
|
1154
|
+
async function executeR34Decision({ctx,events,goal,state,decisionEvent,decision,policy,codingRuntime,
|
|
1155
|
+
nativeDiffRuntime,machineFsRuntime,observationRuntime,processRuntime,semanticRuntime,assertRunAuthority,
|
|
1156
|
+
signingKeyPath,verifyKeyPath}) {
|
|
1157
|
+
let loop=deriveLoopState(goal,events);
|
|
1158
|
+
if (decision.kind === 'plan_create') {
|
|
1159
|
+
if (loop.phase !== 'PLAN' || loop.plan) throw new Error('R34 plan_create requires empty PLANNING state');
|
|
1160
|
+
const plan=createPlan({goalId:goal.goal_id,title:decision.title,steps:decision.steps,
|
|
1161
|
+
reasonHash:r34ReasonHash(goal,decisionEvent,decision.reason ?? 'initial_plan')});
|
|
1162
|
+
await appendEvent(ctx,events,signingKeyPath,'plan_created',{decision_event_sha256:decisionEvent.event_sha256,plan});
|
|
1163
|
+
await r34PhaseChange({ctx,events,goal,signingKeyPath,to:'INSPECT',reason:'plan_ready'});
|
|
1164
|
+
return {status:'completed',plan};
|
|
1165
|
+
}
|
|
1166
|
+
if (!loop.plan) throw new Error(`R34 ${decision.kind} requires a durable plan`);
|
|
1167
|
+
|
|
1168
|
+
if (decision.kind === 'inspect') {
|
|
1169
|
+
if (loop.phase !== 'INSPECT') throw new Error(`R34 inspect requires INSPECTING phase, got ${loop.phase}`);
|
|
1170
|
+
const contexts=[];
|
|
1171
|
+
for (const item of decision.reads) {
|
|
1172
|
+
const read=await codingRuntime.fileRead({rootId:goal.root_id,relativePath:item.path,encoding:'utf8'});
|
|
1173
|
+
const bytes=Buffer.byteLength(read.content,'utf8');
|
|
1174
|
+
if (bytes > item.max_bytes) throw new Error(`R34 inspect '${item.path}' exceeds requested max_bytes`);
|
|
1175
|
+
contexts.push({path:item.path,sha256:read.sha256,bytes:read.bytes,content:read.content,
|
|
1176
|
+
observed_at_utc:new Date().toISOString(),trust_class:'workspace_read',relevance_epoch:state.mutation_epoch});
|
|
1177
|
+
}
|
|
1178
|
+
const evidenceHead=sha256Object({schema:'deadbyte.autonomous-inspection-evidence.v1',contexts});
|
|
1179
|
+
await appendEvent(ctx,events,signingKeyPath,'inspection_completed',{
|
|
1180
|
+
decision_event_sha256:decisionEvent.event_sha256,evidence_head_sha256:evidenceHead,contexts
|
|
1181
|
+
});
|
|
1182
|
+
await r34PhaseChange({ctx,events,goal,signingKeyPath,to:'ACT',reason:'inspection_complete'});
|
|
1183
|
+
return {status:'completed',contexts,evidence_head_sha256:evidenceHead};
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
if (decision.kind === 'act') {
|
|
1187
|
+
if (loop.phase !== 'ACT') throw new Error(`R34 act requires ACTING phase, got ${loop.phase}`);
|
|
1188
|
+
const before={mutation_epoch:state.mutation_epoch,completed_steps:r34CompletedSteps(loop.plan),
|
|
1189
|
+
evidence_head:loop.evidence_head_sha256,release_ready:false,
|
|
1190
|
+
acceptance_failures:state.observations.filter(item=>item?.passed===false).length};
|
|
1191
|
+
let outcome;
|
|
1192
|
+
if (decision.action.kind === 'patch') {
|
|
1193
|
+
await assertRunAuthority(goal.root_id);
|
|
1194
|
+
const currentStep=loop.current_step;
|
|
1195
|
+
if (!currentStep) throw new Error('R34 patch requires active plan step');
|
|
1196
|
+
try {
|
|
1197
|
+
outcome=await executePatch({ctx,events,goal,state,decisionEvent,
|
|
1198
|
+
decision:{operations:decision.action.operations,summary:`R34 ${currentStep.step_id}`},nativeDiffRuntime,
|
|
1199
|
+
policy,codingRuntime,signingKeyPath,actionCoordinatesOverride:{planId:loop.plan_id,
|
|
1200
|
+
planVersion:loop.plan_version,stepId:currentStep.step_id}});
|
|
1201
|
+
} catch (error) {
|
|
1202
|
+
const detail=truncated(error,512);
|
|
1203
|
+
if (!/^native diff precondition '.+' (?:mismatch|expected absent, found [0-9a-f]{64})$/i.test(detail)) throw error;
|
|
1204
|
+
await appendEvent(ctx,events,signingKeyPath,'action_precondition_failed',{
|
|
1205
|
+
decision_event_sha256:decisionEvent.event_sha256,reason:'stale_sha',detail
|
|
1206
|
+
});
|
|
1207
|
+
await r35EnterCritic({ctx,events,goal,signingKeyPath,failureClass:'stale_precondition',detail});
|
|
1208
|
+
return {status:'blocked',reason:'stale_sha'};
|
|
1209
|
+
}
|
|
1210
|
+
} else if (decision.action.kind === 'run_profile') {
|
|
1211
|
+
await assertRunAuthority(goal.root_id);
|
|
1212
|
+
outcome=await executeProfile({ctx,events,goalId:goal.goal_id,
|
|
1213
|
+
actionKey:`r34-${decisionEvent.event_sha256}`,profileId:decision.action.profile_id,
|
|
1214
|
+
epoch:state.mutation_epoch,policy,codingRuntime,signingKeyPath,r34ResumePhase:loop.phase});
|
|
1215
|
+
} else if (decision.action.kind === 'delegate') {
|
|
1216
|
+
outcome=await executeDelegate({ctx,events,goal,decisionEvent,
|
|
1217
|
+
decision:{operation:decision.action.operation},policy,
|
|
1218
|
+
runtimes:{codingRuntime,semanticRuntime,nativeDiffRuntime,machineFsRuntime,observationRuntime,processRuntime},assertRunAuthority,signingKeyPath,verifyKeyPath});
|
|
1219
|
+
} else if (decision.action.kind === 'native_diff_apply') {
|
|
1220
|
+
await assertRunAuthority(goal.root_id);
|
|
1221
|
+
outcome=await executePreparedDiff({ctx,events,goal,state,decisionEvent,diffId:decision.action.diff_id,
|
|
1222
|
+
expectedOperationCount:decision.action.expected_operation_count,policy,codingRuntime,nativeDiffRuntime,signingKeyPath});
|
|
1223
|
+
} else if (['machine_fs_mkdir','machine_fs_move','machine_fs_delete'].includes(decision.action.kind)) {
|
|
1224
|
+
await assertRunAuthority(goal.root_id);
|
|
1225
|
+
if(!machineFsRuntime) throw new Error('machine filesystem runtime unavailable');
|
|
1226
|
+
let operations;
|
|
1227
|
+
if(decision.action.kind==='machine_fs_mkdir') {
|
|
1228
|
+
operations=[{kind:'mkdir',path:decision.action.path}];
|
|
1229
|
+
} else if(decision.action.kind==='machine_fs_move') {
|
|
1230
|
+
operations=[{kind:'move',source_path:decision.action.source_path,destination_path:decision.action.destination_path,
|
|
1231
|
+
expected_source_identity:decision.action.expected_source_identity}];
|
|
1232
|
+
} else {
|
|
1233
|
+
const topology=await machineFsRuntime.state({rootId:goal.root_id,relativePath:decision.action.path});
|
|
1234
|
+
if(!topology.exists||topology.identity_sha256!==decision.action.expected_source_identity) throw new Error(`machine fs delete identity precondition mismatch '${decision.action.path}'`);
|
|
1235
|
+
if(topology.kind==='directory') operations=[{kind:'rmdir',path:decision.action.path,expected_source_identity:decision.action.expected_source_identity}];
|
|
1236
|
+
else {
|
|
1237
|
+
const file=await codingRuntime.fileState({rootId:goal.root_id,relativePath:decision.action.path});
|
|
1238
|
+
if(!file.exists||!SHA256_RE.test(file.sha256??'')) throw new Error(`machine fs delete file precondition unavailable '${decision.action.path}'`);
|
|
1239
|
+
operations=[{kind:'delete',path:decision.action.path,expected_sha256:file.sha256}];
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
outcome=await executePatch({ctx,events,goal,state,decisionEvent,decision:{operations,summary:`R36 ${decision.action.kind}`},
|
|
1243
|
+
nativeDiffRuntime,policy,codingRuntime,signingKeyPath});
|
|
1244
|
+
} else if (capabilityIdForOperation(decision.action)) {
|
|
1245
|
+
outcome=await executeDelegate({ctx,events,goal,decisionEvent,
|
|
1246
|
+
decision:{operation:decision.action},policy,
|
|
1247
|
+
runtimes:{codingRuntime,semanticRuntime,nativeDiffRuntime,machineFsRuntime,observationRuntime,processRuntime},assertRunAuthority,signingKeyPath,verifyKeyPath});
|
|
1248
|
+
} else {
|
|
1249
|
+
throw new Error(`unsupported R34 action '${String(decision.action.kind)}'`);
|
|
1250
|
+
}
|
|
1251
|
+
if (outcome.status === 'paused') return outcome;
|
|
1252
|
+
await r34PhaseChange({ctx,events,goal,signingKeyPath,to:'VERIFY',reason:'action_observed'});
|
|
1253
|
+
const afterState=deriveState(goal,events);
|
|
1254
|
+
loop=deriveLoopState(goal,events);
|
|
1255
|
+
const after={mutation_epoch:afterState.mutation_epoch,completed_steps:r34CompletedSteps(loop.plan),
|
|
1256
|
+
evidence_head:loop.evidence_head_sha256,release_ready:false,
|
|
1257
|
+
acceptance_failures:afterState.observations.filter(item=>item?.passed===false).length};
|
|
1258
|
+
const evidence={
|
|
1259
|
+
native_diff_verified:['patch','native_diff_apply','machine_fs_mkdir','machine_fs_move','machine_fs_delete'].includes(decision.action.kind) && afterState.mutation_epoch > state.mutation_epoch,
|
|
1260
|
+
new_profile_evidence:decision.action.kind === 'run_profile' && outcome.status === 'passed' &&
|
|
1261
|
+
afterState.observations.length > state.observations.length,
|
|
1262
|
+
diagnostic_narrowed:(decision.action.kind === 'delegate' || capabilityIdForOperation(decision.action)) && afterState.observations.length > state.observations.length,
|
|
1263
|
+
interrupted_action_recovered:outcome.recovered === true
|
|
1264
|
+
};
|
|
1265
|
+
const progress=judgeProgress({before,after,decision,evidence});
|
|
1266
|
+
await appendEvent(ctx,events,signingKeyPath,'progress_judged',{
|
|
1267
|
+
decision_event_sha256:decisionEvent.event_sha256,...progress
|
|
1268
|
+
});
|
|
1269
|
+
if (progress.verdict === 'regressed') {
|
|
1270
|
+
await r35EnterCritic({ctx,events,goal,signingKeyPath,failureClass:'verification_failure',
|
|
1271
|
+
evidenceFingerprint:progress.fingerprint,detail:'verification regressed against observed acceptance evidence'});
|
|
1272
|
+
} else if (progress.verdict === 'stalled') {
|
|
1273
|
+
const disposition=stallDisposition({history:r34ProgressHistory(events),limits:policy.limits});
|
|
1274
|
+
if (disposition.action === 'replan') {
|
|
1275
|
+
await r35EnterCritic({ctx,events,goal,signingKeyPath,failureClass:'no_progress',
|
|
1276
|
+
evidenceFingerprint:progress.fingerprint,detail:disposition.reason});
|
|
1277
|
+
} else if (disposition.action === 'wait') {
|
|
1278
|
+
await r35EnterCritic({ctx,events,goal,signingKeyPath,failureClass:'no_progress',
|
|
1279
|
+
evidenceFingerprint:progress.fingerprint,detail:disposition.reason});
|
|
1280
|
+
return r34EnterWaiting({ctx,events,goal,signingKeyPath,reason:'no_progress_after_replan',resumePhase:'CRITIC'});
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
return outcome;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
if (decision.kind === 'step_complete') {
|
|
1287
|
+
if (loop.phase !== 'VERIFY') throw new Error(`R34 step_complete requires VERIFYING phase, got ${loop.phase}`);
|
|
1288
|
+
const beforeCount=r34CompletedSteps(loop.plan);
|
|
1289
|
+
const plan=completePlanStep(loop.plan,{stepId:decision.step_id,evidence:decision.evidence});
|
|
1290
|
+
await appendEvent(ctx,events,signingKeyPath,'step_completed',{
|
|
1291
|
+
decision_event_sha256:decisionEvent.event_sha256,step_id:decision.step_id,evidence:decision.evidence,plan
|
|
1292
|
+
});
|
|
1293
|
+
const progress=judgeProgress({
|
|
1294
|
+
before:{mutation_epoch:state.mutation_epoch,completed_steps:beforeCount},
|
|
1295
|
+
after:{mutation_epoch:state.mutation_epoch,completed_steps:r34CompletedSteps(plan)},
|
|
1296
|
+
decision,evidence:{step_evidence_verified:true}
|
|
1297
|
+
});
|
|
1298
|
+
await appendEvent(ctx,events,signingKeyPath,'progress_judged',{
|
|
1299
|
+
decision_event_sha256:decisionEvent.event_sha256,...progress
|
|
1300
|
+
});
|
|
1301
|
+
const target=r34PlanIsComplete(plan)?'PLAN':'INSPECT';
|
|
1302
|
+
await r34PhaseChange({ctx,events,goal,signingKeyPath,to:target,reason:r34PlanIsComplete(plan)?'plan_complete':'next_plan_step'});
|
|
1303
|
+
return {status:'completed',plan};
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
if (decision.kind === 'replan') {
|
|
1307
|
+
if (!['CRITIC','REPAIR'].includes(loop.phase)) {
|
|
1308
|
+
if (!['VERIFY','PLAN'].includes(loop.phase)) throw new Error(`R35 replan invalid from ${loop.phase}`);
|
|
1309
|
+
loop=await r35EnterCritic({ctx,events,goal,signingKeyPath,failureClass:'insufficient_proof',
|
|
1310
|
+
evidenceFingerprint:loop.progress?.fingerprint,detail:decision.reason});
|
|
1311
|
+
}
|
|
1312
|
+
const repair=await r35BeginRepair({ctx,events,goal,signingKeyPath,hypothesis:decision.reason});
|
|
1313
|
+
loop=repair.loop;
|
|
1314
|
+
const completed=loop.plan.steps.filter(step=>step.status==='completed').map(step=>structuredClone(step));
|
|
1315
|
+
const plan=replanPlan(loop.plan,{steps:[...completed,...decision.steps],
|
|
1316
|
+
reasonHash:r34ReasonHash(goal,decisionEvent,decision.reason)});
|
|
1317
|
+
await appendEvent(ctx,events,signingKeyPath,'plan_replanned',{
|
|
1318
|
+
decision_event_sha256:decisionEvent.event_sha256,reason:decision.reason,plan
|
|
1319
|
+
});
|
|
1320
|
+
await r35CompleteRepair({ctx,events,goal,signingKeyPath,previousFingerprint:repair.previousFingerprint,
|
|
1321
|
+
hypothesis:decision.reason});
|
|
1322
|
+
await r34PhaseChange({ctx,events,goal,signingKeyPath,to:'INSPECT',reason:'repair_ready'});
|
|
1323
|
+
return {status:'completed',plan};
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
if (decision.kind === 'pause') {
|
|
1327
|
+
return r34EnterWaiting({ctx,events,goal,signingKeyPath,reason:decision.reason,resumePhase:loop.phase});
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
if (decision.kind === 'finish') {
|
|
1331
|
+
if (!r34PlanIsComplete(loop.plan)) {
|
|
1332
|
+
await appendEvent(ctx,events,signingKeyPath,'plan_guard_blocked',{
|
|
1333
|
+
decision_event_sha256:decisionEvent.event_sha256,action:'finish',
|
|
1334
|
+
reason:'plan_incomplete_blocks_finish',plan_id:loop.plan_id,plan_version:loop.plan_version
|
|
1335
|
+
});
|
|
1336
|
+
return {status:'blocked',reason:'plan_incomplete_blocks_finish'};
|
|
1337
|
+
}
|
|
1338
|
+
if (loop.phase !== 'PLAN') throw new Error(`R34 finish requires PLANNING phase, got ${loop.phase}`);
|
|
1339
|
+
await appendEvent(ctx,events,signingKeyPath,'finish_requested',{
|
|
1340
|
+
decision_event_sha256:decisionEvent.event_sha256,mutation_epoch:state.mutation_epoch,
|
|
1341
|
+
planner_summary:decision.summary ?? 'R34 finish'
|
|
1342
|
+
});
|
|
1343
|
+
await r34PhaseChange({ctx,events,goal,signingKeyPath,to:'RELEASE',reason:'finish_requested'});
|
|
1344
|
+
return {status:'finish_requested'};
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
throw new Error(`unsupported R34 decision '${String(decision.kind)}'`);
|
|
1348
|
+
}
|
|
1349
|
+
|
|
699
1350
|
async function executeDecision({ ctx, events, goal, state, decisionEvent, policy, codingRuntime,
|
|
700
|
-
nativeDiffRuntime, machineFsRuntime, observationRuntime, processRuntime, assertRunAuthority,
|
|
1351
|
+
nativeDiffRuntime, machineFsRuntime, observationRuntime, processRuntime, semanticRuntime, assertRunAuthority,
|
|
701
1352
|
signingKeyPath, verifyKeyPath }) {
|
|
702
1353
|
const decision = decisionEvent.decision;
|
|
1354
|
+
if (decision?.schema === 'deadbyte.autonomous-decision.v2') {
|
|
1355
|
+
const outcome=await executeR34Decision({ctx,events,goal,state,decisionEvent,decision,policy,codingRuntime,
|
|
1356
|
+
nativeDiffRuntime,machineFsRuntime,observationRuntime,processRuntime,semanticRuntime,assertRunAuthority,
|
|
1357
|
+
signingKeyPath,verifyKeyPath});
|
|
1358
|
+
await appendEvent(ctx,events,signingKeyPath,'decision_completed',{
|
|
1359
|
+
decision_event_sha256:decisionEvent.event_sha256,action:decision.kind,
|
|
1360
|
+
outcome_status:outcome.status ?? 'completed'
|
|
1361
|
+
});
|
|
1362
|
+
return outcome;
|
|
1363
|
+
}
|
|
703
1364
|
if (repeatedDecisionCount(state,decision) >= 3) {
|
|
704
1365
|
await appendEvent(ctx,events,signingKeyPath,'goal_paused',{ reason:'no_progress_repeated_decision' });
|
|
705
1366
|
return { status:'paused' };
|
|
@@ -757,11 +1418,30 @@ function terminalState(state) {
|
|
|
757
1418
|
return ['succeeded','cancelled'].includes(state.state);
|
|
758
1419
|
}
|
|
759
1420
|
function pauseState(state) { return state.state === 'paused'; }
|
|
1421
|
+
async function resumeProviderWaitIfReady({ctx,journal,goal,state,policy,signingKeyPath}) {
|
|
1422
|
+
if (state.state!=='paused'||state.reason!=='provider_circuit_open'||policy.planner.backend!=='openai_compatible') return state;
|
|
1423
|
+
const circuit=providerCircuitSnapshot(policy,journal);
|
|
1424
|
+
const disposition=providerCallDisposition(circuit);
|
|
1425
|
+
if (!disposition.allowed||circuit.state!=='HALF_OPEN') return state;
|
|
1426
|
+
const waiting=[...journal].reverse().find(event=>event.type==='waiting_entered'&&event.payload?.reason==='provider_circuit_open')??null;
|
|
1427
|
+
const resumePhase=typeof waiting?.payload?.resume_phase==='string'?waiting.payload.resume_phase:'PLAN';
|
|
1428
|
+
await appendEvent(ctx,journal,signingKeyPath,'waiting_resumed',{
|
|
1429
|
+
to:resumePhase,reason:'provider_circuit_half_open',approved_at_utc:new Date().toISOString()
|
|
1430
|
+
});
|
|
1431
|
+
await appendEvent(ctx,journal,signingKeyPath,'goal_resumed',{
|
|
1432
|
+
previous_reason:'provider_circuit_open',approved_at_utc:new Date().toISOString()
|
|
1433
|
+
});
|
|
1434
|
+
return deriveState(goal,journal);
|
|
1435
|
+
}
|
|
1436
|
+
function isAuthorityUnavailable(error) {
|
|
1437
|
+
return /(?:disarmed|lease|outside active lease|authority unavailable)/i.test(String(error?.message ?? error));
|
|
1438
|
+
}
|
|
760
1439
|
|
|
761
1440
|
export function createAutonomousRuntime({ policy, codingRuntime, nativeDiffRuntime, machineFsRuntime = null,
|
|
762
|
-
observationRuntime = null, processRuntime = null, signingKeyPath, verifyKeyPath }) {
|
|
1441
|
+
observationRuntime = null, processRuntime = null, semanticRuntime = null, signingKeyPath, verifyKeyPath }) {
|
|
763
1442
|
if (!policy || !codingRuntime || !nativeDiffRuntime) throw new Error('autonomous runtime requires policy/coding/native-diff runtimes');
|
|
764
1443
|
if (!signingKeyPath || !verifyKeyPath) throw new Error('autonomous runtime requires trust keys');
|
|
1444
|
+
const capabilityManifest=configuredCapabilityManifest({machineFsRuntime,observationRuntime,processRuntime,semanticRuntime});
|
|
765
1445
|
async function sessionStatus() {
|
|
766
1446
|
const autonomous = await autonomousSessionStatus(policy);
|
|
767
1447
|
const coding = await codingRuntime.sessionStatus();
|
|
@@ -773,6 +1453,13 @@ export function createAutonomousRuntime({ policy, codingRuntime, nativeDiffRunti
|
|
|
773
1453
|
profile_ids:Object.keys(policy.profiles), policy_sha256:policy.policy_sha256,
|
|
774
1454
|
coding_policy_sha256:policy.coding_policy_sha256 };
|
|
775
1455
|
}
|
|
1456
|
+
async function providerCircuitStatus({goalId}) {
|
|
1457
|
+
if (policy.planner.backend!=='openai_compatible') return null;
|
|
1458
|
+
const ctx=goalContext(policy,goalId);
|
|
1459
|
+
await loadGoal(ctx,policy,verifyKeyPath);
|
|
1460
|
+
const journal=await readEvents(ctx,verifyKeyPath);
|
|
1461
|
+
return providerCircuitSnapshot(policy,journal);
|
|
1462
|
+
}
|
|
776
1463
|
|
|
777
1464
|
async function assertRunAuthority(rootId) {
|
|
778
1465
|
const autonomous = await assertAutonomousArmed(policy,rootId);
|
|
@@ -812,8 +1499,10 @@ export function createAutonomousRuntime({ policy, codingRuntime, nativeDiffRunti
|
|
|
812
1499
|
const goal = await loadGoal(ctx,policy,verifyKeyPath);
|
|
813
1500
|
const journal = await readEvents(ctx,verifyKeyPath);
|
|
814
1501
|
const derived = deriveState(goal,journal);
|
|
1502
|
+
const loop = publicLoopState(loopStateOrNull(goal,journal));
|
|
815
1503
|
return { status:'ok', goal_id:goalId, goal_sha256:goal.goal_sha256,
|
|
816
|
-
title:goal.title, root_id:goal.root_id, journal_verified:true, ...derived
|
|
1504
|
+
title:goal.title, root_id:goal.root_id, journal_verified:true, ...derived,
|
|
1505
|
+
...(loop ? {loop} : {}) };
|
|
817
1506
|
}
|
|
818
1507
|
|
|
819
1508
|
async function events({ goalId, fromSeq = 1, limit = 100 }) {
|
|
@@ -851,16 +1540,25 @@ export function createAutonomousRuntime({ policy, codingRuntime, nativeDiffRunti
|
|
|
851
1540
|
const goal = await loadGoal(ctx,policy,verifyKeyPath);
|
|
852
1541
|
const journal = await readEvents(ctx,verifyKeyPath);
|
|
853
1542
|
const current = deriveState(goal,journal);
|
|
854
|
-
if (terminalState(current)) return { status:'terminal', goal_id:goalId, state:current.state };
|
|
1543
|
+
if (terminalState(current)) return withLoopResult(goal,journal,{ status:'terminal', goal_id:goalId, state:current.state });
|
|
855
1544
|
if (!pauseState(current)) throw new Error('autonomous goal is not paused');
|
|
856
1545
|
if (decision === 'reject') {
|
|
857
1546
|
await appendEvent(ctx,journal,signingKeyPath,'goal_cancelled',{ reason:'resume_rejected' });
|
|
858
|
-
return { status:'rejected', goal_id:goalId, state:'cancelled' };
|
|
1547
|
+
return withLoopResult(goal,journal,{ status:'rejected', goal_id:goalId, state:'cancelled' });
|
|
1548
|
+
}
|
|
1549
|
+
if (hasR34Loop(journal)) {
|
|
1550
|
+
await assertRunAuthority(goal.root_id);
|
|
1551
|
+
const waiting=[...journal].reverse().find(event=>event.type==='waiting_entered') ?? null;
|
|
1552
|
+
const resumePhase=typeof waiting?.payload?.resume_phase === 'string' ? waiting.payload.resume_phase : 'PLAN';
|
|
1553
|
+
await appendEvent(ctx,journal,signingKeyPath,'waiting_resumed',{
|
|
1554
|
+
to:resumePhase,reason:waiting?.payload?.reason ?? current.reason ?? 'operator_approved',
|
|
1555
|
+
approved_at_utc:new Date().toISOString()
|
|
1556
|
+
});
|
|
859
1557
|
}
|
|
860
1558
|
await appendEvent(ctx,journal,signingKeyPath,'goal_resumed',{
|
|
861
1559
|
previous_reason:current.reason, approved_at_utc:new Date().toISOString()
|
|
862
1560
|
});
|
|
863
|
-
return { status:'approved', goal_id:goalId, state:'running' };
|
|
1561
|
+
return withLoopResult(goal,journal,{ status:'approved', goal_id:goalId, state:'running' });
|
|
864
1562
|
} finally {
|
|
865
1563
|
await releaseLock(ctx);
|
|
866
1564
|
}
|
|
@@ -927,55 +1625,80 @@ export function createAutonomousRuntime({ policy, codingRuntime, nativeDiffRunti
|
|
|
927
1625
|
if (!Number.isInteger(maxCycles) || maxCycles < 1 || maxCycles > 32) throw new Error('autonomous max_cycles must be in [1,32]');
|
|
928
1626
|
const ctx = goalContext(policy,goalId);
|
|
929
1627
|
const goal = await loadGoal(ctx,policy,verifyKeyPath);
|
|
930
|
-
await assertRunAuthority(goal.root_id);
|
|
931
1628
|
await acquireLock(ctx);
|
|
932
1629
|
try {
|
|
933
1630
|
const journal = await readEvents(ctx,verifyKeyPath);
|
|
934
1631
|
let state = deriveState(goal,journal);
|
|
935
|
-
if (terminalState(state)) return { status:'terminal', goal_id:goalId, ...state };
|
|
936
|
-
|
|
1632
|
+
if (terminalState(state)) return withLoopResult(goal,journal,{ status:'terminal', goal_id:goalId, ...state });
|
|
1633
|
+
state=await resumeProviderWaitIfReady({ctx,journal,goal,state,policy,signingKeyPath});
|
|
1634
|
+
if (pauseState(state)) return withLoopResult(goal,journal,{ status:'paused', goal_id:goalId, ...state });
|
|
1635
|
+
const loopBeforeAuthority = loopStateOrNull(goal,journal);
|
|
1636
|
+
try {
|
|
1637
|
+
await assertRunAuthority(goal.root_id);
|
|
1638
|
+
} catch (error) {
|
|
1639
|
+
if (!loopBeforeAuthority || !isAuthorityUnavailable(error)) throw error;
|
|
1640
|
+
const waiting=await r34EnterWaiting({ctx,events:journal,goal,signingKeyPath,
|
|
1641
|
+
reason:'authority_unavailable',resumePhase:loopBeforeAuthority.phase});
|
|
1642
|
+
state=deriveState(goal,journal);
|
|
1643
|
+
return withLoopResult(goal,journal,{...waiting,goal_id:goalId,...state});
|
|
1644
|
+
}
|
|
937
1645
|
if (await consumeCancel(ctx,journal,signingKeyPath,verifyKeyPath)) {
|
|
938
|
-
state = deriveState(goal,journal); return { status:'cancelled', goal_id:goalId, ...state };
|
|
1646
|
+
state = deriveState(goal,journal); return withLoopResult(goal,journal,{ status:'cancelled', goal_id:goalId, ...state });
|
|
939
1647
|
}
|
|
940
1648
|
await appendEvent(ctx,journal,signingKeyPath,'goal_run_started',{ max_cycles:maxCycles });
|
|
941
1649
|
let cycles = 0; let suppliedResponse = plannerResponse;
|
|
942
1650
|
while (cycles < maxCycles) {
|
|
943
1651
|
state = deriveState(goal,journal);
|
|
944
|
-
if (terminalState(state) || pauseState(state)) return { status:state.state, goal_id:goalId, ...state };
|
|
1652
|
+
if (terminalState(state) || pauseState(state)) return withLoopResult(goal,journal,{ status:state.state, goal_id:goalId, ...state });
|
|
945
1653
|
if (await consumeCancel(ctx,journal,signingKeyPath,verifyKeyPath)) {
|
|
946
|
-
state = deriveState(goal,journal); return { status:'cancelled', goal_id:goalId, ...state };
|
|
1654
|
+
state = deriveState(goal,journal); return withLoopResult(goal,journal,{ status:'cancelled', goal_id:goalId, ...state });
|
|
947
1655
|
}
|
|
948
1656
|
if (state.pending_decision) {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1657
|
+
let outcome;
|
|
1658
|
+
try {
|
|
1659
|
+
outcome = await executeDecision({ ctx,events:journal,goal,state,
|
|
1660
|
+
decisionEvent:state.pending_decision,policy,codingRuntime,nativeDiffRuntime,machineFsRuntime,
|
|
1661
|
+
observationRuntime,processRuntime,semanticRuntime,assertRunAuthority,signingKeyPath,verifyKeyPath });
|
|
1662
|
+
} catch (error) {
|
|
1663
|
+
const loop=loopStateOrNull(goal,journal);
|
|
1664
|
+
if (!loop || loop.pending_action || !isAuthorityUnavailable(error)) throw error;
|
|
1665
|
+
outcome=await r34EnterWaiting({ctx,events:journal,goal,signingKeyPath,
|
|
1666
|
+
reason:'authority_unavailable',resumePhase:loop.phase});
|
|
1667
|
+
}
|
|
952
1668
|
cycles += 1; state = deriveState(goal,journal);
|
|
953
|
-
if (outcome.status === 'paused' || pauseState(state)) return { status:'paused', goal_id:goalId, ...state };
|
|
1669
|
+
if (outcome.status === 'paused' || pauseState(state)) return withLoopResult(goal,journal,{ status:'paused', goal_id:goalId, ...state });
|
|
954
1670
|
if (outcome.status === 'finish_requested') {
|
|
955
1671
|
const gate = await releaseGateLocked(ctx,goal,journal);
|
|
956
1672
|
state = deriveState(goal,journal);
|
|
957
|
-
if (gate.status === 'passed') return { status:'completed', goal_id:goalId, release:gate, ...state };
|
|
958
|
-
if (gate.status === 'paused') return { status:'paused', goal_id:goalId, release:gate, ...state };
|
|
1673
|
+
if (gate.status === 'passed') return withLoopResult(goal,journal,{ status:'completed', goal_id:goalId, release:gate, ...state });
|
|
1674
|
+
if (gate.status === 'paused') return withLoopResult(goal,journal,{ status:'paused', goal_id:goalId, release:gate, ...state });
|
|
1675
|
+
const releaseLoop=loopStateOrNull(goal,journal);
|
|
1676
|
+
if (releaseLoop?.phase === 'RELEASE') {
|
|
1677
|
+
await r35EnterCritic({ctx,events:journal,goal,signingKeyPath,failureClass:'verification_failure',
|
|
1678
|
+
evidenceFingerprint:sha256Object({schema:'deadbyte.autonomous-release-failure.v1',gate}),
|
|
1679
|
+
detail:`release gate ${gate.status}: ${gate.reason ?? 'required profile failure'}`});
|
|
1680
|
+
state=deriveState(goal,journal);
|
|
1681
|
+
}
|
|
959
1682
|
}
|
|
960
1683
|
continue;
|
|
961
1684
|
}
|
|
962
|
-
const accepted = await acceptPlannerDecision({ ctx,events:journal,goal,state,policy,codingRuntime,
|
|
1685
|
+
const accepted = await acceptPlannerDecision({ ctx,events:journal,goal,state,policy,codingRuntime,capabilityManifest,
|
|
963
1686
|
signingKeyPath,plannerResponse:suppliedResponse });
|
|
964
1687
|
suppliedResponse = null;
|
|
965
1688
|
if (accepted?.needs_planner) {
|
|
966
1689
|
state = deriveState(goal,journal);
|
|
967
|
-
return { status:'input_required', goal_id:goalId,
|
|
1690
|
+
return withLoopResult(goal,journal,{ status:'input_required', goal_id:goalId,
|
|
968
1691
|
planner_request:{ request_id:accepted.request.request_id,
|
|
969
1692
|
planner_round:accepted.request.planner_round,
|
|
970
1693
|
mutation_epoch:accepted.request.mutation_epoch,
|
|
971
1694
|
prompt:accepted.request.prompt,
|
|
972
|
-
prompt_sha256:accepted.request.prompt_sha256 }, ...state };
|
|
1695
|
+
prompt_sha256:accepted.request.prompt_sha256 }, ...state });
|
|
973
1696
|
}
|
|
974
1697
|
state = deriveState(goal,journal);
|
|
975
|
-
if (pauseState(state)) return { status:'paused', goal_id:goalId, ...state };
|
|
1698
|
+
if (pauseState(state)) return withLoopResult(goal,journal,{ status:'paused', goal_id:goalId, ...state });
|
|
976
1699
|
}
|
|
977
1700
|
state = deriveState(goal,journal);
|
|
978
|
-
return { status:'yielded', goal_id:goalId, cycles, ...state };
|
|
1701
|
+
return withLoopResult(goal,journal,{ status:'yielded', goal_id:goalId, cycles, ...state });
|
|
979
1702
|
} finally { await releaseLock(ctx); }
|
|
980
1703
|
}
|
|
981
1704
|
|
|
@@ -988,6 +1711,6 @@ export function createAutonomousRuntime({ policy, codingRuntime, nativeDiffRunti
|
|
|
988
1711
|
return verifyReleaseReceipt({ ctx,goal,events:journal,policy,verifyKeyPath,nativeDiffRuntime,codingRuntime });
|
|
989
1712
|
}
|
|
990
1713
|
|
|
991
|
-
return Object.freeze({ policy, sessionStatus, submit, run, status, events, cancel, approve,
|
|
1714
|
+
return Object.freeze({ policy, sessionStatus, providerCircuitStatus, submit, run, status, events, cancel, approve,
|
|
992
1715
|
releaseGate, verify });
|
|
993
1716
|
}
|