deadbyte-mcp 0.8.9 → 0.9.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 +348 -83
- package/R34-BASELINE.json +9 -0
- package/README.txt +135 -9
- package/bench/fixtures/corpus.json +17 -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 +10 -4
- package/controller/deadbyte-controller.config.psd1.example +14 -0
- package/controller/deadbyte-controller.ps1 +144 -19
- package/controller/deadbyte-process-policy.json +5 -5
- package/controller/deadbyte-semantic-lsp-config.json +95 -0
- package/deadbyte-mcp-0.8.9.tgz +0 -0
- package/docs/ADR-0001-PRODUCTION-BASELINE-SEAMS.md +29 -0
- package/docs/ARCHITECTURE.md +6 -5
- 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/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/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 +4 -2
- package/scripts/final-closure-verify.mjs +10 -10
- package/scripts/final-closure.mjs +11 -11
- package/scripts/gate-windows.ps1 +3 -3
- package/scripts/release-parity.mjs +14 -14
- 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 +255 -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-output-contracts.mjs +22 -3
- package/src/autonomous-plan.mjs +181 -0
- package/src/autonomous-planner-contracts.mjs +44 -0
- package/src/autonomous-planner.mjs +91 -6
- package/src/autonomous-policy.mjs +15 -2
- package/src/autonomous-progress.mjs +127 -0
- package/src/autonomous-runtime.mjs +601 -48
- package/src/autonomous-supervisor-host.mjs +70 -0
- package/src/autonomous-supervisor.mjs +31 -8
- package/src/capability-benchmark-runner.mjs +108 -0
- package/src/capability-benchmark.mjs +50 -0
- package/src/coding-mcp-tools.mjs +46 -3
- package/src/coding-output-contracts.mjs +45 -0
- package/src/context-provenance.mjs +86 -0
- package/src/deadbyte-cli.mjs +136 -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/mcp-server.mjs +17 -3
- package/src/observation-smoke-client.mjs +3 -2
- package/src/operator-surface.mjs +37 -0
- package/src/provider-circuit.mjs +125 -0
- package/src/release-generation.mjs +44 -5
- package/src/remote-mcp-autonomous-smoke-client.mjs +53 -14
- 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-r33-parity-client.mjs +1 -1
- package/src/remote-mcp-r34-parity-client.mjs +177 -0
- package/src/remote-mcp-smoke-client.mjs +2 -1
- package/src/remote-result-journal.mjs +114 -0
- package/src/runtime-update.mjs +58 -8
- package/src/semantic-backend-registry.mjs +39 -0
- package/src/semantic-code.mjs +179 -0
- package/src/semantic-lsp-backend.mjs +183 -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-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-runner.test.mjs +49 -0
- package/test/capability-benchmark.test.mjs +47 -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/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 +2 -1
- package/test/document-adapter.test.mjs +23 -0
- package/test/fixtures/lsp-framed-server.mjs +33 -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 +120 -0
- package/test/lsp-stdio-client.test.mjs +72 -0
- package/test/multi-file-read.test.mjs +41 -0
- package/test/observation-integration.test.mjs +3 -3
- package/test/production-docs.test.mjs +48 -0
- package/test/prompts-resources.test.mjs +35 -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 +3 -3
- package/test/r33-finalization.test.mjs +19 -16
- package/test/release-generation.test.mjs +23 -2
- package/test/release-version.test.mjs +24 -17
- package/test/remote-r24-catalog.test.mjs +5 -4
- package/test/remote-result-journal.test.mjs +58 -0
- package/test/remote-session-cli.test.mjs +150 -15
- package/test/runtime-self-update.test.mjs +63 -0
- package/test/semantic-backend-registry.test.mjs +29 -0
- package/test/semantic-code.test.mjs +66 -0
- package/test/semantic-lsp-backend.test.mjs +99 -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-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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
|
|
5
|
+
import { StdioClientTransport, getDefaultEnvironment } from '@modelcontextprotocol/client/stdio';
|
|
6
|
+
import { snapshotToolsListResult } from '../src/tool-surface-ledger.mjs';
|
|
7
|
+
|
|
8
|
+
function parseArgs(argv){
|
|
9
|
+
const out={input:'',endpointFile:'',output:''};
|
|
10
|
+
for(let i=0;i<argv.length;i+=1){
|
|
11
|
+
const arg=argv[i];
|
|
12
|
+
if(arg==='--input') out.input=argv[++i]??'';
|
|
13
|
+
else if(arg==='--endpoint-file') out.endpointFile=argv[++i]??'';
|
|
14
|
+
else if(arg==='--output') out.output=argv[++i]??'';
|
|
15
|
+
else throw new Error(`unknown argument: ${arg}`);
|
|
16
|
+
}
|
|
17
|
+
if(Boolean(out.input)===Boolean(out.endpointFile)) throw new Error('use exactly one of --input or --endpoint-file');
|
|
18
|
+
if(!out.input&&!out.endpointFile) throw new Error('missing snapshot source');
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function listFromEndpointFile(endpointFile){
|
|
23
|
+
const endpointText=(await readFile(path.resolve(endpointFile),'utf8')).trim();
|
|
24
|
+
const endpoint=new URL(endpointText);
|
|
25
|
+
if(endpoint.protocol!=='https:') throw new Error('tool surface endpoint must use HTTPS');
|
|
26
|
+
const client=new Client({name:'deadbyte-r35-tool-surface',version:'0.9.0'},{versionNegotiation:{mode:{pin:'2026-07-28'}}});
|
|
27
|
+
const transport=new StreamableHTTPClientTransport(endpoint);
|
|
28
|
+
try{
|
|
29
|
+
await client.connect(transport);
|
|
30
|
+
return await client.listTools();
|
|
31
|
+
} finally {
|
|
32
|
+
await client.close().catch(()=>{});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function snapshotStdioServer({command,args=[],cwd=process.cwd(),env={}}){
|
|
37
|
+
if(typeof command!=='string'||command.length<1) throw new Error('stdio snapshot command required');
|
|
38
|
+
if(!Array.isArray(args)||args.some(arg=>typeof arg!=='string')) throw new Error('stdio snapshot args must be strings');
|
|
39
|
+
const client=new Client({name:'deadbyte-r35-tool-surface-stdio',version:'0.9.0'},{versionNegotiation:{mode:{pin:'2026-07-28'}}});
|
|
40
|
+
const transport=new StdioClientTransport({
|
|
41
|
+
command,
|
|
42
|
+
args,
|
|
43
|
+
cwd,
|
|
44
|
+
env:{...getDefaultEnvironment(),...env},
|
|
45
|
+
stderr:'pipe'
|
|
46
|
+
});
|
|
47
|
+
try{
|
|
48
|
+
await client.connect(transport);
|
|
49
|
+
return snapshotToolsListResult(await client.listTools());
|
|
50
|
+
} finally {
|
|
51
|
+
await client.close().catch(()=>{});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function snapshotSource({input='',endpointFile=''}){
|
|
56
|
+
const listed=input
|
|
57
|
+
? JSON.parse(await readFile(path.resolve(input),'utf8'))
|
|
58
|
+
: await listFromEndpointFile(endpointFile);
|
|
59
|
+
return snapshotToolsListResult(listed);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function main(argv=process.argv.slice(2)){
|
|
63
|
+
const args=parseArgs(argv);
|
|
64
|
+
const snapshot=await snapshotSource(args);
|
|
65
|
+
const text=`${JSON.stringify(snapshot,null,2)}\n`;
|
|
66
|
+
if(args.output) await writeFile(path.resolve(args.output),text,{encoding:'utf8',flag:'w'});
|
|
67
|
+
else process.stdout.write(text);
|
|
68
|
+
return snapshot;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){
|
|
72
|
+
main().catch(error=>{console.error(error instanceof Error?error.stack:String(error));process.exitCode=1;});
|
|
73
|
+
}
|
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
const here=path.dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
const root=path.resolve(here,'..');
|
|
9
9
|
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
10
|
-
const marker='DEADBYTE V0.
|
|
10
|
+
const marker='DEADBYTE V0.9.0 / R35 WINDOWS BATCH GATE: PASS';
|
|
11
11
|
function insist(ok,message){if(!ok) throw new Error(message);}
|
|
12
12
|
|
|
13
13
|
export async function writeWindowsGateEvidence({
|
|
@@ -19,17 +19,17 @@ export async function writeWindowsGateEvidence({
|
|
|
19
19
|
const manifestBytes=await readFile(path.join(candidate,'MANIFEST.SHA256'));
|
|
20
20
|
const manifestSha256=sha256(manifestBytes);
|
|
21
21
|
const pkg=JSON.parse(await readFile(path.join(candidate,'package.json'),'utf8'));
|
|
22
|
-
insist(pkg.version==='0.
|
|
22
|
+
insist(pkg.version==='0.9.0',`Windows gate evidence requires V0.9.0, found ${pkg.version}`);
|
|
23
23
|
const completed=clock();
|
|
24
24
|
insist(completed instanceof Date&&!Number.isNaN(completed.getTime()),'Windows gate evidence clock invalid');
|
|
25
25
|
const evidence={
|
|
26
|
-
schema:'deadbyte.
|
|
26
|
+
schema:'deadbyte.r35-windows-gate.v1',status:'passed',exit_code:0,version:'0.9.0',
|
|
27
27
|
marker,completed_at_utc:completed.toISOString(),manifest_sha256:manifestSha256
|
|
28
28
|
};
|
|
29
29
|
const bytes=Buffer.from(`${JSON.stringify(evidence,null,2)}\n`,'utf8');
|
|
30
30
|
const dir=path.join(path.resolve(stateRoot),'evidence','release');
|
|
31
31
|
await mkdir(dir,{recursive:true});
|
|
32
|
-
const file=path.join(dir,`
|
|
32
|
+
const file=path.join(dir,`r35-windows-gate-${manifestSha256.slice(0,16)}.json`);
|
|
33
33
|
try{
|
|
34
34
|
const handle=await open(file,'wx',0o600);
|
|
35
35
|
try{await handle.writeFile(bytes);await handle.sync();}finally{await handle.close();}
|
|
@@ -39,7 +39,7 @@ export async function writeWindowsGateEvidence({
|
|
|
39
39
|
const existingBytes=await readFile(file);
|
|
40
40
|
const existing=JSON.parse(existingBytes.toString('utf8'));
|
|
41
41
|
insist(existing.schema===evidence.schema&&existing.status==='passed'&&existing.exit_code===0,'existing Windows gate evidence invalid');
|
|
42
|
-
insist(existing.version==='0.
|
|
42
|
+
insist(existing.version==='0.9.0'&&existing.marker===marker&&existing.manifest_sha256===manifestSha256,'existing Windows gate evidence binding mismatch');
|
|
43
43
|
return {status:'existing',path:file,sha256:sha256(existingBytes),manifest_sha256:manifestSha256};
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/audit-verify.mjs
CHANGED
|
@@ -43,6 +43,8 @@ export async function verifyAuditChain({stateRoot,verifyKeyPath,requireComplete=
|
|
|
43
43
|
|
|
44
44
|
let seq=0,head=ZERO,previousCheckpoint=ZERO,requestCount=0,resultCount=0,checkpointCount=0;
|
|
45
45
|
const open=new Map();
|
|
46
|
+
const usage=new Map();
|
|
47
|
+
const usageFor=tool=>{ if(!usage.has(tool)) usage.set(tool,{tool,requests:0,results:0,errors:0}); return usage.get(tool); };
|
|
46
48
|
for(let pos=0;pos<segmentIndexes.length;pos++){
|
|
47
49
|
const index=segmentIndexes[pos],fileName=segmentName(index),file=path.join(auditDir,fileName),bytes=await readFile(file),rows=parseSegment(bytes,fileName);
|
|
48
50
|
const firstSeq=seq+1,firstPrev=head;
|
|
@@ -59,11 +61,12 @@ export async function verifyAuditChain({stateRoot,verifyKeyPath,requireComplete=
|
|
|
59
61
|
if(event.event_type==='tool.request'){
|
|
60
62
|
if(open.has(event.request_id)) throw new Error(`audit duplicate request id at seq ${event.seq}`);
|
|
61
63
|
if(event.args===undefined) throw new Error(`audit request args missing at seq ${event.seq}`);
|
|
62
|
-
open.set(event.request_id,{tool:event.tool,seq:event.seq,segment:index});requestCount++;
|
|
64
|
+
open.set(event.request_id,{tool:event.tool,seq:event.seq,segment:index});requestCount++;usageFor(event.tool).requests++;
|
|
63
65
|
}else if(event.event_type==='tool.result'){
|
|
64
66
|
const pending=open.get(event.request_id);if(!pending) throw new Error(`audit orphan result at seq ${event.seq}`);
|
|
65
67
|
if(pending.tool!==event.tool) throw new Error(`audit result tool mismatch at seq ${event.seq}`);
|
|
66
68
|
requireObject(event.outcome,`audit outcome at seq ${event.seq}`);
|
|
69
|
+
const stats=usageFor(event.tool);stats.results++;if(event.outcome.is_error===true)stats.errors++;
|
|
67
70
|
open.delete(event.request_id);resultCount++;
|
|
68
71
|
}else throw new Error(`audit event type invalid at seq ${event.seq}`);
|
|
69
72
|
seq=event.seq;head=event.event_sha256;
|
|
@@ -88,6 +91,7 @@ export async function verifyAuditChain({stateRoot,verifyKeyPath,requireComplete=
|
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
if(requireComplete&&open.size>0) throw new Error(`audit has ${open.size} request(s) without result`);
|
|
91
|
-
|
|
94
|
+
const toolUsage=[...usage.values()].sort((a,b)=>a.tool.localeCompare(b.tool,'en'));
|
|
95
|
+
return {ok:true,event_count:seq,request_count:requestCount,result_count:resultCount,open_request_count:open.size,segment_count:segmentIndexes.length,checkpoint_count:checkpointCount,last_seq:seq,head_sha256:head,last_checkpoint_sha256:previousCheckpoint,key_id:key.keyId,complete:open.size===0,tool_usage:toolUsage};
|
|
92
96
|
}catch(error){return {ok:false,reason:String(error?.message||error)};}
|
|
93
97
|
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { canonicalJson } from './canonical-json.mjs';
|
|
3
|
+
|
|
4
|
+
const HEX64 = /^[0-9a-f]{64}$/;
|
|
5
|
+
const ID = /^[A-Za-z0-9._-]{1,64}$/;
|
|
6
|
+
const RECEIPT_ID = /^[0-9a-f]{24}$/;
|
|
7
|
+
|
|
8
|
+
function sha256Object(value) {
|
|
9
|
+
return createHash('sha256').update(Buffer.from(canonicalJson(value),'utf8')).digest('hex');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function hash(value,label) {
|
|
13
|
+
if (typeof value !== 'string' || !HEX64.test(value)) throw new Error(`${label} invalid`);
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function id(value,label) {
|
|
18
|
+
if (typeof value !== 'string' || !ID.test(value)) throw new Error(`${label} invalid`);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function integer(value,label) {
|
|
23
|
+
if (!Number.isInteger(value) || value < 0) throw new Error(`${label} invalid`);
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function classification(classification,evidence = null,reason = null) {
|
|
28
|
+
return Object.freeze({
|
|
29
|
+
classification,
|
|
30
|
+
replay_allowed:classification === 'not_executed',
|
|
31
|
+
evidence:evidence === null ? null : Object.freeze({...evidence}),
|
|
32
|
+
reason
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function actionIdentity({ goalId, planId, planVersion, stepId, mutationEpoch, decisionEventSha, action }) {
|
|
37
|
+
hash(goalId,'action goalId');
|
|
38
|
+
hash(planId,'action planId');
|
|
39
|
+
if (!Number.isInteger(planVersion) || planVersion < 1) throw new Error('action planVersion invalid');
|
|
40
|
+
id(stepId,'action stepId');
|
|
41
|
+
integer(mutationEpoch,'action mutationEpoch');
|
|
42
|
+
hash(decisionEventSha,'action decisionEventSha');
|
|
43
|
+
if (!action || typeof action !== 'object' || Array.isArray(action)) throw new Error('action payload invalid');
|
|
44
|
+
const request = {
|
|
45
|
+
schema:'deadbyte.autonomous-action-request.v1',
|
|
46
|
+
goal_id:goalId,
|
|
47
|
+
plan_id:planId,
|
|
48
|
+
plan_version:planVersion,
|
|
49
|
+
step_id:stepId,
|
|
50
|
+
mutation_epoch:mutationEpoch,
|
|
51
|
+
decision_event_sha256:decisionEventSha,
|
|
52
|
+
action:structuredClone(action)
|
|
53
|
+
};
|
|
54
|
+
const requestSha256 = sha256Object(request);
|
|
55
|
+
const actionId = sha256Object({schema:'deadbyte.autonomous-action-id.v1',request_sha256:requestSha256});
|
|
56
|
+
return Object.freeze({ action_id:actionId, request_sha256:requestSha256 });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function missingEvidence(reason) {
|
|
60
|
+
return typeof reason === 'string' && /(?:missing|not found|unavailable|enoent|absent)/i.test(reason);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function validateStarted(startedEvent) {
|
|
64
|
+
if (!startedEvent || typeof startedEvent !== 'object' || startedEvent.type !== 'action_started') {
|
|
65
|
+
throw new Error('reconcile requires action_started event');
|
|
66
|
+
}
|
|
67
|
+
const payload = startedEvent.payload;
|
|
68
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) throw new Error('action_started payload invalid');
|
|
69
|
+
hash(payload.action_id,'started action_id');
|
|
70
|
+
hash(payload.request_sha256,'started request_sha256');
|
|
71
|
+
if (!payload.action || typeof payload.action !== 'object' || Array.isArray(payload.action)) throw new Error('started action payload missing');
|
|
72
|
+
return payload;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function reconcilePatch(payload,runtimes) {
|
|
76
|
+
const diffId = hash(payload.action.diff_id,'started patch diff_id');
|
|
77
|
+
if (!runtimes?.nativeDiffRuntime?.verify) return classification('ambiguous',null,'native diff verifier unavailable');
|
|
78
|
+
let checked;
|
|
79
|
+
try { checked = await runtimes.nativeDiffRuntime.verify({diffId}); }
|
|
80
|
+
catch (error) {
|
|
81
|
+
const reason = String(error?.message ?? error);
|
|
82
|
+
return missingEvidence(reason) ? classification('not_executed',null,reason) : classification('ambiguous',null,reason);
|
|
83
|
+
}
|
|
84
|
+
if (checked?.ok === true) {
|
|
85
|
+
if (checked.current_state_matches !== true) return classification('ambiguous',null,'native diff current state mismatch');
|
|
86
|
+
if (!HEX64.test(checked.receipt_sha256 ?? '')) return classification('ambiguous',null,'native diff verified without receipt hash');
|
|
87
|
+
return classification('executed_verified',{
|
|
88
|
+
kind:'native_diff',
|
|
89
|
+
diff_id:diffId,
|
|
90
|
+
receipt_sha256:checked.receipt_sha256,
|
|
91
|
+
...(HEX64.test(checked.journal_head_sha256 ?? '') ? {journal_head_sha256:checked.journal_head_sha256} : {})
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const reason = String(checked?.reason ?? 'native diff verification failed');
|
|
95
|
+
return missingEvidence(reason) ? classification('not_executed',null,reason) : classification('ambiguous',null,reason);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function reconcileProfile(payload,runtimes) {
|
|
99
|
+
const receiptId = payload.action.receipt_id;
|
|
100
|
+
if (typeof receiptId !== 'string' || !RECEIPT_ID.test(receiptId)) return classification('ambiguous',null,'profile receipt id invalid');
|
|
101
|
+
if (!runtimes?.codingRuntime?.verifyReceiptDetailed) return classification('ambiguous',null,'coding receipt verifier unavailable');
|
|
102
|
+
let checked;
|
|
103
|
+
try { checked = await runtimes.codingRuntime.verifyReceiptDetailed(receiptId); }
|
|
104
|
+
catch (error) {
|
|
105
|
+
const reason = String(error?.message ?? error);
|
|
106
|
+
return missingEvidence(reason) ? classification('not_executed',null,reason) : classification('ambiguous',null,reason);
|
|
107
|
+
}
|
|
108
|
+
if (checked?.ok !== true) {
|
|
109
|
+
const reason = String(checked?.reason ?? 'coding receipt verification failed');
|
|
110
|
+
return missingEvidence(reason) ? classification('not_executed',null,reason) : classification('ambiguous',null,reason);
|
|
111
|
+
}
|
|
112
|
+
if (checked.request_sha256 !== payload.request_sha256) return classification('ambiguous',null,'coding receipt request identity mismatch');
|
|
113
|
+
if (!HEX64.test(checked.receipt_sha256 ?? '')) return classification('ambiguous',null,'coding receipt hash invalid');
|
|
114
|
+
const receipt = checked.receipt;
|
|
115
|
+
if (!receipt || receipt.receipt_id !== receiptId) return classification('ambiguous',null,'coding receipt substitution detected');
|
|
116
|
+
const evidence = {kind:'coding_receipt',receipt_id:receiptId,receipt_sha256:checked.receipt_sha256,request_sha256:checked.request_sha256};
|
|
117
|
+
if (receipt.operation === 'coding_command_run') {
|
|
118
|
+
const expected = Number.isInteger(payload.action.expect_exit_code) ? payload.action.expect_exit_code : 0;
|
|
119
|
+
const passed = receipt.timed_out !== true && receipt.exit_code === expected;
|
|
120
|
+
return classification(passed ? 'executed_verified' : 'executed_failed_verified',evidence,passed ? null : 'verified command outcome failed');
|
|
121
|
+
}
|
|
122
|
+
if (receipt.operation === 'coding_benchmark_run') {
|
|
123
|
+
const passed = receipt.verdict === 'pass';
|
|
124
|
+
return classification(passed ? 'executed_verified' : 'executed_failed_verified',evidence,passed ? null : 'verified benchmark outcome failed');
|
|
125
|
+
}
|
|
126
|
+
return classification('ambiguous',null,'coding receipt operation mismatch');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export async function reconcileStartedAction({ startedEvent, journal = [], runtimes = {} } = {}) {
|
|
130
|
+
const payload = validateStarted(startedEvent);
|
|
131
|
+
if (!Array.isArray(journal)) throw new Error('reconcile journal must be an array');
|
|
132
|
+
const completed = journal.find(event => event?.type === 'action_completed' && event?.payload?.action_id === payload.action_id);
|
|
133
|
+
if (completed) {
|
|
134
|
+
return classification('executed_verified',{
|
|
135
|
+
kind:'journal_completion',
|
|
136
|
+
event_sha256:HEX64.test(completed.event_sha256 ?? '') ? completed.event_sha256 : null
|
|
137
|
+
},'matching verified journal completion already exists');
|
|
138
|
+
}
|
|
139
|
+
if (payload.action.kind === 'patch') return reconcilePatch(payload,runtimes);
|
|
140
|
+
if (payload.action.kind === 'profile') return reconcileProfile(payload,runtimes);
|
|
141
|
+
return classification('ambiguous',null,`unsupported interrupted action kind '${String(payload.action.kind)}'`);
|
|
142
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { canonicalJson } from './canonical-json.mjs';
|
|
3
|
+
import { provenanceFor, dedupeEvidence } from './context-provenance.mjs';
|
|
4
|
+
|
|
5
|
+
const SECRET_KEY = /(?:^|[_-])(token|password|secret|authorization|cookie|credential|credentials|api[_-]?key|private[_-]?key|recovery)(?:$|[_-])/i;
|
|
6
|
+
const HEX64 = /^[0-9a-f]{64}$/;
|
|
7
|
+
|
|
8
|
+
const sha256Text = text => createHash('sha256').update(Buffer.from(text,'utf8')).digest('hex');
|
|
9
|
+
const bytesOf = value => Buffer.byteLength(canonicalJson(value),'utf8');
|
|
10
|
+
|
|
11
|
+
function utf8Bytes(value) {
|
|
12
|
+
if (typeof value === 'string') return Buffer.byteLength(value,'utf8');
|
|
13
|
+
return Buffer.byteLength(canonicalJson(value),'utf8');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function sanitize(value,key = '') {
|
|
17
|
+
if (SECRET_KEY.test(key)) {
|
|
18
|
+
return { redacted:true, reason:'secret', byte_count:utf8Bytes(value) };
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(value)) return value.map(item => sanitize(item,''));
|
|
21
|
+
if (value && typeof value === 'object') {
|
|
22
|
+
const out = {};
|
|
23
|
+
for (const name of Object.keys(value).sort()) out[name] = sanitize(value[name],name);
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function elideStringField(object,field,{hash = true}={}) {
|
|
30
|
+
if (!object || typeof object !== 'object' || typeof object[field] !== 'string') return false;
|
|
31
|
+
const text = object[field];
|
|
32
|
+
object[`${field}_elided`] = true;
|
|
33
|
+
object[`${field}_bytes`] = Buffer.byteLength(text,'utf8');
|
|
34
|
+
if (hash) object[`${field}_sha256`] = sha256Text(text);
|
|
35
|
+
delete object[field];
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function compactHistorical(state,fits) {
|
|
40
|
+
const events = state.historical_evidence?.compacted_events ?? [];
|
|
41
|
+
for (const event of events) {
|
|
42
|
+
for (const field of ['raw_payload','content','stdout_excerpt','stderr_excerpt','old_string','new_string','data_base64']) {
|
|
43
|
+
elideStringField(event,field);
|
|
44
|
+
}
|
|
45
|
+
if (fits()) return;
|
|
46
|
+
}
|
|
47
|
+
const observations = state.historical_evidence?.observations ?? [];
|
|
48
|
+
for (const observation of observations) {
|
|
49
|
+
for (const field of ['stdout_excerpt','stderr_excerpt','content','raw_payload']) elideStringField(observation,field);
|
|
50
|
+
if (fits()) return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function compactWorking(state,fits) {
|
|
55
|
+
const contexts = state.working_context?.recent_contexts ?? [];
|
|
56
|
+
for (let index = 0; index < Math.max(0,contexts.length - 1) && !fits(); index += 1) {
|
|
57
|
+
elideStringField(contexts[index],'content');
|
|
58
|
+
}
|
|
59
|
+
const observations = state.working_context?.recent_observations ?? [];
|
|
60
|
+
for (let index = 0; index < Math.max(0,observations.length - 1) && !fits(); index += 1) {
|
|
61
|
+
elideStringField(observations[index],'stdout_excerpt');
|
|
62
|
+
elideStringField(observations[index],'stderr_excerpt');
|
|
63
|
+
elideStringField(observations[index],'content');
|
|
64
|
+
}
|
|
65
|
+
if (!fits() && Array.isArray(state.working_context?.tree) && state.working_context.tree.length > 128) {
|
|
66
|
+
const original = state.working_context.tree.length;
|
|
67
|
+
state.working_context.tree = state.working_context.tree.slice(0,128);
|
|
68
|
+
state.working_context.tree_compaction = { original_entries:original, kept_entries:128 };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function compactLoopContext(input,maxBytes) {
|
|
73
|
+
if (!Number.isInteger(maxBytes) || maxBytes < 1024) throw new Error('loop context maxBytes invalid');
|
|
74
|
+
const state = sanitize(structuredClone(input));
|
|
75
|
+
const fits = () => bytesOf(state) <= maxBytes;
|
|
76
|
+
if (fits()) return state;
|
|
77
|
+
compactHistorical(state,fits);
|
|
78
|
+
if (fits()) return state;
|
|
79
|
+
compactWorking(state,fits);
|
|
80
|
+
if (fits()) return state;
|
|
81
|
+
throw new Error('autonomous loop context exceeds policy budget after deterministic compaction');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function uniqueStrings(values) {
|
|
85
|
+
return [...new Set(values.filter(value => typeof value === 'string' && value.length > 0))];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function deriveProjectMemory(events) {
|
|
89
|
+
if (!Array.isArray(events)) throw new Error('project memory events must be an array');
|
|
90
|
+
const acceptance = [];
|
|
91
|
+
const proven = [];
|
|
92
|
+
const rejected = [];
|
|
93
|
+
const files = new Map();
|
|
94
|
+
const blockers = new Map();
|
|
95
|
+
|
|
96
|
+
for (const event of events) {
|
|
97
|
+
if (!event || typeof event !== 'object' || Array.isArray(event)) continue;
|
|
98
|
+
const payload = event.payload && typeof event.payload === 'object' && !Array.isArray(event.payload) ? event.payload : {};
|
|
99
|
+
if (event.type === 'goal_created' && typeof payload.acceptance === 'string' && payload.acceptance.length > 0) {
|
|
100
|
+
acceptance.push(payload.acceptance);
|
|
101
|
+
}
|
|
102
|
+
if (event.type === 'profile_completed' && typeof payload.profile_id === 'string') {
|
|
103
|
+
const key = `profile:${payload.profile_id}`;
|
|
104
|
+
if (payload.passed === false) blockers.set(key,`${payload.profile_id}_failed`);
|
|
105
|
+
if (payload.passed === true) {
|
|
106
|
+
blockers.delete(key);
|
|
107
|
+
proven.push(`${payload.profile_id}:passed`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (event.type === 'planner_rejected' && typeof payload.reason === 'string') rejected.push(payload.reason);
|
|
111
|
+
if (event.type === 'native_diff_committed') {
|
|
112
|
+
for (const file of payload.paths ?? []) {
|
|
113
|
+
if (typeof file === 'string' && file.length > 0) {
|
|
114
|
+
files.set(file,{ path:file, ...(HEX64.test(payload.diff_receipt_sha256 ?? '') ? { receipt_sha256:payload.diff_receipt_sha256 } : {}) });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (event.type === 'waiting_entered' && typeof payload.reason === 'string') blockers.set(`wait:${payload.reason}`,payload.reason);
|
|
119
|
+
if (event.type === 'waiting_resumed' && typeof payload.previous_reason === 'string') blockers.delete(`wait:${payload.previous_reason}`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
acceptance_constraints:uniqueStrings(acceptance),
|
|
124
|
+
proven_invariants:uniqueStrings(proven),
|
|
125
|
+
rejected_approaches:uniqueStrings(rejected),
|
|
126
|
+
important_files:[...files.values()].sort((a,b) => a.path.localeCompare(b.path,'en')),
|
|
127
|
+
unresolved_blockers:[...blockers.values()].sort((a,b) => a.localeCompare(b,'en'))
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const LEGACY_OBSERVED_AT_UTC='1970-01-01T00:00:00.000Z';
|
|
132
|
+
|
|
133
|
+
function provenancePayload(item,kind){
|
|
134
|
+
if(kind==='context'&&typeof item?.content==='string') return item.content;
|
|
135
|
+
const payload=structuredClone(item??{});
|
|
136
|
+
delete payload.provenance;
|
|
137
|
+
delete payload.observed_at_utc;
|
|
138
|
+
delete payload.trust_class;
|
|
139
|
+
delete payload.relevance_epoch;
|
|
140
|
+
return payload;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function provenanceSourceId(item,kind,index){
|
|
144
|
+
const candidates=kind==='context'
|
|
145
|
+
? [item?.source_id,item?.path,HEX64.test(item?.sha256??'')?`sha256:${item.sha256}`:null]
|
|
146
|
+
: [item?.source_id,item?.profile_id?`profile:${item.profile_id}`:null,HEX64.test(item?.request_sha256??'')?`request:${item.request_sha256}`:null,item?.session_id?`session:${item.session_id}`:null,item?.search_id?`search:${item.search_id}`:null,item?.diff_id?`diff:${item.diff_id}`:null,HEX64.test(item?.receipt_sha256??'')?`receipt:${item.receipt_sha256}`:null];
|
|
147
|
+
const selected=candidates.find(value=>typeof value==='string'&&value.length>0);
|
|
148
|
+
return selected??`${kind}:legacy:${index}`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function normalizeEvidence(items,{kind,relevanceEpoch}){
|
|
152
|
+
if(!Array.isArray(items)) throw new Error(`${kind} evidence must be an array`);
|
|
153
|
+
const mapped=items.map((item,index)=>{
|
|
154
|
+
if(!item||typeof item!=='object'||Array.isArray(item)) throw new Error(`${kind} evidence ${index+1} invalid`);
|
|
155
|
+
if(item.provenance) return structuredClone(item);
|
|
156
|
+
const observed=typeof item.observed_at_utc==='string'&&item.observed_at_utc.length>0?item.observed_at_utc:LEGACY_OBSERVED_AT_UTC;
|
|
157
|
+
const stamped={...structuredClone(item)};
|
|
158
|
+
if(!stamped.observed_at_utc) stamped.observed_at_utc=observed;
|
|
159
|
+
stamped.provenance=provenanceFor({
|
|
160
|
+
sourceKind:kind,
|
|
161
|
+
sourceId:provenanceSourceId(item,kind,index),
|
|
162
|
+
bytes:provenancePayload(item,kind),
|
|
163
|
+
observedAtUtc:observed,
|
|
164
|
+
trustClass:typeof item.trust_class==='string'&&item.trust_class.length>0?item.trust_class:(observed===LEGACY_OBSERVED_AT_UTC?'legacy_unstamped':kind==='context'?'workspace_read':HEX64.test(item.receipt_sha256??'')?'signed_receipt':'runtime_observation'),
|
|
165
|
+
relevanceEpoch:Number.isInteger(item.relevance_epoch)&&item.relevance_epoch>=0?item.relevance_epoch:relevanceEpoch
|
|
166
|
+
});
|
|
167
|
+
return stamped;
|
|
168
|
+
});
|
|
169
|
+
return dedupeEvidence(mapped);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function activeIdentities(observations) {
|
|
173
|
+
const out = [];
|
|
174
|
+
const seen = new Set();
|
|
175
|
+
for (const observation of observations) {
|
|
176
|
+
if (!observation || typeof observation !== 'object') continue;
|
|
177
|
+
for (const field of ['session_id','search_id','diff_id','receipt_id']) {
|
|
178
|
+
const value = observation[field] ?? observation.result?.[field] ?? observation.evidence?.[field];
|
|
179
|
+
if (typeof value !== 'string' || value.length < 1) continue;
|
|
180
|
+
const key = `${field}:${value}`;
|
|
181
|
+
if (seen.has(key)) continue;
|
|
182
|
+
seen.add(key);
|
|
183
|
+
out.push({ kind:field.replace(/_id$/,''), id:value });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function historicalEvidence({ contexts, observations, loopState }) {
|
|
190
|
+
const oldContexts = contexts.slice(0,Math.max(0,contexts.length - 16)).map(item => ({ kind:'context', ...structuredClone(item) }));
|
|
191
|
+
const oldObservations = observations.slice(0,Math.max(0,observations.length - 24)).map(item => ({ kind:'observation', ...structuredClone(item) }));
|
|
192
|
+
const failures = observations.filter(item => item?.passed === false || item?.status === 'failed' || item?.error)
|
|
193
|
+
.map(item => ({
|
|
194
|
+
profile_id:item.profile_id ?? null,
|
|
195
|
+
cause:item.reason ?? item.error ?? (item.profile_id ? `${item.profile_id}_failed` : 'operation_failed'),
|
|
196
|
+
...(HEX64.test(item.receipt_sha256 ?? '') ? { receipt_sha256:item.receipt_sha256 } : {})
|
|
197
|
+
}));
|
|
198
|
+
const receipts = observations.filter(item => HEX64.test(item?.receipt_sha256 ?? '')).map(item => ({
|
|
199
|
+
receipt_id:typeof item.receipt_id === 'string' ? item.receipt_id : null,
|
|
200
|
+
receipt_sha256:item.receipt_sha256,
|
|
201
|
+
...(HEX64.test(item.request_sha256 ?? '') ? { request_sha256:item.request_sha256 } : {})
|
|
202
|
+
}));
|
|
203
|
+
const mutationEpochs = uniqueStrings(observations.map(item => Number.isInteger(item?.mutation_epoch) ? String(item.mutation_epoch) : ''))
|
|
204
|
+
.map(Number);
|
|
205
|
+
if (Number.isInteger(loopState?.mutation_epoch) && !mutationEpochs.includes(loopState.mutation_epoch)) mutationEpochs.push(loopState.mutation_epoch);
|
|
206
|
+
mutationEpochs.sort((a,b) => a-b);
|
|
207
|
+
return {
|
|
208
|
+
compacted_events:[...oldContexts,...oldObservations],
|
|
209
|
+
failures,
|
|
210
|
+
receipts,
|
|
211
|
+
mutation_epochs:mutationEpochs,
|
|
212
|
+
plan_transitions:[]
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function buildLoopContext({ goal, policy, loopState = {}, tree = [], contexts = [], observations = [], decisions = [], projectMemory = null }) {
|
|
217
|
+
if (!policy?.limits || !Number.isInteger(policy.limits.max_context_bytes)) throw new Error('loop context policy byte limit missing');
|
|
218
|
+
const relevanceEpoch=Number.isInteger(loopState?.mutation_epoch)&&loopState.mutation_epoch>=0?loopState.mutation_epoch:0;
|
|
219
|
+
const retainedContexts=normalizeEvidence(contexts,{kind:'context',relevanceEpoch});
|
|
220
|
+
const retainedObservations=normalizeEvidence(observations,{kind:'observation',relevanceEpoch});
|
|
221
|
+
const profiles = Object.entries(policy.profiles ?? {}).map(([id,profile]) => ({
|
|
222
|
+
id,
|
|
223
|
+
kind:profile.kind,
|
|
224
|
+
required_for_release:profile.required_for_release === true,
|
|
225
|
+
description:profile.description ?? ''
|
|
226
|
+
}));
|
|
227
|
+
const memory = projectMemory === null ? {
|
|
228
|
+
acceptance_constraints:typeof goal?.acceptance === 'string' && goal.acceptance.length > 0 ? [goal.acceptance] : [],
|
|
229
|
+
proven_invariants:[],rejected_approaches:[],important_files:[],unresolved_blockers:[]
|
|
230
|
+
} : structuredClone(projectMemory);
|
|
231
|
+
const state = {
|
|
232
|
+
goal:structuredClone(goal ?? {}),
|
|
233
|
+
loop:{
|
|
234
|
+
phase:loopState.phase ?? null,
|
|
235
|
+
mutation_epoch:Number.isInteger(loopState.mutation_epoch) ? loopState.mutation_epoch : 0,
|
|
236
|
+
planner_round:Number.isInteger(loopState.planner_round) ? loopState.planner_round : 0,
|
|
237
|
+
plan_id:loopState.plan_id ?? null,
|
|
238
|
+
plan_version:loopState.plan_version ?? null,
|
|
239
|
+
replan_count:Number.isInteger(loopState.replan_count) ? loopState.replan_count : 0
|
|
240
|
+
},
|
|
241
|
+
working_context:{
|
|
242
|
+
active_plan:structuredClone(loopState.plan ?? loopState.active_plan ?? null),
|
|
243
|
+
current_step:structuredClone(loopState.current_step ?? null),
|
|
244
|
+
recent_contexts:structuredClone(retainedContexts.slice(-16)),
|
|
245
|
+
recent_observations:structuredClone(retainedObservations.slice(-24)),
|
|
246
|
+
active_identities:activeIdentities(retainedObservations.slice(-24)),
|
|
247
|
+
recent_decisions:structuredClone(decisions.slice(-8)),
|
|
248
|
+
tree:structuredClone(tree)
|
|
249
|
+
},
|
|
250
|
+
historical_evidence:historicalEvidence({contexts:retainedContexts,observations:retainedObservations,loopState}),
|
|
251
|
+
project_memory:memory,
|
|
252
|
+
profiles
|
|
253
|
+
};
|
|
254
|
+
return compactLoopContext(state,policy.limits.max_context_bytes);
|
|
255
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function promptContexts(state) {
|
|
2
|
+
if (Array.isArray(state?.working_context?.recent_contexts)) return state.working_context.recent_contexts;
|
|
3
|
+
if (Array.isArray(state?.contexts)) return state.contexts;
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function promptObservations(state) {
|
|
8
|
+
if (Array.isArray(state?.working_context?.recent_observations)) return state.working_context.recent_observations;
|
|
9
|
+
if (Array.isArray(state?.observations)) return state.observations;
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function promptMutationEpoch(state) {
|
|
14
|
+
if (Number.isInteger(state?.loop?.mutation_epoch)) return state.loop.mutation_epoch;
|
|
15
|
+
if (Number.isInteger(state?.mutation_epoch)) return state.mutation_epoch;
|
|
16
|
+
return 0;
|
|
17
|
+
}
|