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.
Files changed (349) hide show
  1. package/CONTEXT.md +41 -0
  2. package/MANIFEST.SHA256 +348 -83
  3. package/R34-BASELINE.json +9 -0
  4. package/README.txt +135 -9
  5. package/bench/fixtures/corpus.json +17 -0
  6. package/bin/WORKER-REGISTRY.txt +3 -3
  7. package/bin/appcontainer-stage.exe +0 -0
  8. package/bin/appcontainer-stage.obj +0 -0
  9. package/bin/bootstrap-advapi32.exe +0 -0
  10. package/bin/bootstrap-advapi32.obj +0 -0
  11. package/bin/bootstrap-exitcode.exe +0 -0
  12. package/bin/bootstrap-exitcode.obj +0 -0
  13. package/bin/bootstrap-kernel32.exe +0 -0
  14. package/bin/bootstrap-kernel32.obj +0 -0
  15. package/bin/child-control-probe.exe +0 -0
  16. package/bin/child-control-probe.obj +0 -0
  17. package/bin/child-control-stage.exe +0 -0
  18. package/bin/child-control-stage.obj +0 -0
  19. package/bin/contained-reverse-worker.exe +0 -0
  20. package/bin/contained-reverse-worker.obj +0 -0
  21. package/bin/contained-transform-worker.exe +0 -0
  22. package/bin/contained-transform-worker.obj +0 -0
  23. package/bin/containment-probe.exe +0 -0
  24. package/bin/containment-probe.obj +0 -0
  25. package/bin/deadbyte-contain.exe +0 -0
  26. package/bin/deadbyte-contain.obj +0 -0
  27. package/bin/deadbyte-exec.exe +0 -0
  28. package/bin/deadbyte-exec.obj +0 -0
  29. package/bin/deadbyte-process-host.exe +0 -0
  30. package/bin/deadbyte-process-host.obj +0 -0
  31. package/bin/deadbyte-tunnel-host.exe +0 -0
  32. package/bin/deadbyte-tunnel-host.obj +0 -0
  33. package/controller/README.TXT +10 -4
  34. package/controller/deadbyte-controller.config.psd1.example +14 -0
  35. package/controller/deadbyte-controller.ps1 +144 -19
  36. package/controller/deadbyte-process-policy.json +5 -5
  37. package/controller/deadbyte-semantic-lsp-config.json +95 -0
  38. package/deadbyte-mcp-0.8.9.tgz +0 -0
  39. package/docs/ADR-0001-PRODUCTION-BASELINE-SEAMS.md +29 -0
  40. package/docs/ARCHITECTURE.md +6 -5
  41. package/docs/superpowers/plans/2026-09-16-deadbyte-loop-engine.md +846 -0
  42. package/docs/superpowers/plans/2026-09-17-r35-production-successor.md +408 -0
  43. package/docs/superpowers/specs/2026-09-16-deadbyte-loop-engine-design.md +435 -0
  44. package/docs/superpowers/specs/2026-09-17-r35-production-successor-design.md +220 -0
  45. package/node_modules/typescript/LICENSE.txt +55 -0
  46. package/node_modules/typescript/README.md +50 -0
  47. package/node_modules/typescript/SECURITY.md +41 -0
  48. package/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  49. package/node_modules/typescript/bin/tsc +2 -0
  50. package/node_modules/typescript/bin/tsserver +2 -0
  51. package/node_modules/typescript/lib/_tsc.js +133818 -0
  52. package/node_modules/typescript/lib/_tsserver.js +659 -0
  53. package/node_modules/typescript/lib/_typingsInstaller.js +222 -0
  54. package/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
  55. package/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
  56. package/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
  57. package/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
  58. package/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
  59. package/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
  60. package/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
  61. package/node_modules/typescript/lib/lib.d.ts +22 -0
  62. package/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
  63. package/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
  64. package/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
  65. package/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
  66. package/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
  67. package/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
  68. package/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
  69. package/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
  70. package/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
  71. package/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
  72. package/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
  73. package/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
  74. package/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
  75. package/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
  76. package/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
  77. package/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
  78. package/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
  79. package/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
  80. package/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
  81. package/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
  82. package/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
  83. package/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
  84. package/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
  85. package/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
  86. package/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
  87. package/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
  88. package/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
  89. package/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
  90. package/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
  91. package/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
  92. package/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
  93. package/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
  94. package/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
  95. package/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
  96. package/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
  97. package/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
  98. package/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
  99. package/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
  100. package/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
  101. package/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
  102. package/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
  103. package/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
  104. package/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
  105. package/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
  106. package/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
  107. package/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
  108. package/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
  109. package/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
  110. package/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
  111. package/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
  112. package/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
  113. package/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
  114. package/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
  115. package/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
  116. package/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
  117. package/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
  118. package/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
  119. package/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
  120. package/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
  121. package/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
  122. package/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
  123. package/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
  124. package/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
  125. package/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
  126. package/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
  127. package/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
  128. package/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
  129. package/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
  130. package/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
  131. package/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
  132. package/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
  133. package/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
  134. package/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
  135. package/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
  136. package/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
  137. package/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
  138. package/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
  139. package/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
  140. package/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
  141. package/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
  142. package/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
  143. package/node_modules/typescript/lib/lib.es6.d.ts +23 -0
  144. package/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
  145. package/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
  146. package/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
  147. package/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
  148. package/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
  149. package/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
  150. package/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
  151. package/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
  152. package/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
  153. package/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
  154. package/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
  155. package/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
  156. package/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
  157. package/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
  158. package/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
  159. package/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
  160. package/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
  161. package/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
  162. package/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
  163. package/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
  164. package/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
  165. package/node_modules/typescript/lib/tsc.js +8 -0
  166. package/node_modules/typescript/lib/tsserver.js +8 -0
  167. package/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
  168. package/node_modules/typescript/lib/tsserverlibrary.js +21 -0
  169. package/node_modules/typescript/lib/typesMap.json +497 -0
  170. package/node_modules/typescript/lib/typescript.d.ts +11437 -0
  171. package/node_modules/typescript/lib/typescript.js +200276 -0
  172. package/node_modules/typescript/lib/typingsInstaller.js +8 -0
  173. package/node_modules/typescript/lib/watchGuard.js +53 -0
  174. package/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
  175. package/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
  176. package/node_modules/typescript/package.json +120 -0
  177. package/package.json +5 -3
  178. package/proof/CONTAINMENT-BUILD.txt +6 -6
  179. package/proof/R34-TASK8-SUPERVISOR-CHECKPOINT.json +29 -0
  180. package/proof/R34-TASK9-MCP-SURFACE-CHECKPOINT.json +28 -0
  181. package/scripts/capability-benchmark.mjs +27 -0
  182. package/scripts/deferred-slot-operation.mjs +4 -2
  183. package/scripts/final-closure-verify.mjs +10 -10
  184. package/scripts/final-closure.mjs +11 -11
  185. package/scripts/gate-windows.ps1 +3 -3
  186. package/scripts/release-parity.mjs +14 -14
  187. package/scripts/semantic-preflight.ps1 +73 -0
  188. package/scripts/tool-surface-snapshot.mjs +73 -0
  189. package/scripts/windows-gate-evidence.mjs +5 -5
  190. package/src/audit-verify.mjs +6 -2
  191. package/src/autonomous-action-reconcile.mjs +142 -0
  192. package/src/autonomous-context-engine.mjs +255 -0
  193. package/src/autonomous-live-state.mjs +17 -0
  194. package/src/autonomous-local-supervisor.mjs +249 -0
  195. package/src/autonomous-loop-state.mjs +304 -0
  196. package/src/autonomous-output-contracts.mjs +22 -3
  197. package/src/autonomous-plan.mjs +181 -0
  198. package/src/autonomous-planner-contracts.mjs +44 -0
  199. package/src/autonomous-planner.mjs +91 -6
  200. package/src/autonomous-policy.mjs +15 -2
  201. package/src/autonomous-progress.mjs +127 -0
  202. package/src/autonomous-runtime.mjs +601 -48
  203. package/src/autonomous-supervisor-host.mjs +70 -0
  204. package/src/autonomous-supervisor.mjs +31 -8
  205. package/src/capability-benchmark-runner.mjs +108 -0
  206. package/src/capability-benchmark.mjs +50 -0
  207. package/src/coding-mcp-tools.mjs +46 -3
  208. package/src/coding-output-contracts.mjs +45 -0
  209. package/src/context-provenance.mjs +86 -0
  210. package/src/deadbyte-cli.mjs +136 -30
  211. package/src/document-adapter.mjs +43 -0
  212. package/src/lsp-stdio-client.mjs +112 -0
  213. package/src/machine-fs-smoke-client.mjs +2 -1
  214. package/src/mcp-server.mjs +17 -3
  215. package/src/observation-smoke-client.mjs +3 -2
  216. package/src/operator-surface.mjs +37 -0
  217. package/src/provider-circuit.mjs +125 -0
  218. package/src/release-generation.mjs +44 -5
  219. package/src/remote-mcp-autonomous-smoke-client.mjs +53 -14
  220. package/src/remote-mcp-coding-smoke-client.mjs +5 -4
  221. package/src/remote-mcp-r24-disarmed-smoke-client.mjs +4 -2
  222. package/src/remote-mcp-r33-parity-client.mjs +1 -1
  223. package/src/remote-mcp-r34-parity-client.mjs +177 -0
  224. package/src/remote-mcp-smoke-client.mjs +2 -1
  225. package/src/remote-result-journal.mjs +114 -0
  226. package/src/runtime-update.mjs +58 -8
  227. package/src/semantic-backend-registry.mjs +39 -0
  228. package/src/semantic-code.mjs +179 -0
  229. package/src/semantic-lsp-backend.mjs +183 -0
  230. package/src/semantic-lsp-config.mjs +112 -0
  231. package/src/tool-surface-ledger.mjs +92 -0
  232. package/src/version.mjs +1 -1
  233. package/test/audit-verify.test.mjs +1 -1
  234. package/test/autonomous-action-reconcile.test.mjs +106 -0
  235. package/test/autonomous-adversarial.test.mjs +149 -6
  236. package/test/autonomous-context-engine.test.mjs +181 -0
  237. package/test/autonomous-live-state.test.mjs +27 -0
  238. package/test/autonomous-local-supervisor.test.mjs +403 -0
  239. package/test/autonomous-loop-state.test.mjs +126 -0
  240. package/test/autonomous-loop-v2.test.mjs +105 -0
  241. package/test/autonomous-loop.test.mjs +79 -1
  242. package/test/autonomous-output-contract.test.mjs +54 -0
  243. package/test/autonomous-plan.test.mjs +101 -0
  244. package/test/autonomous-progress.test.mjs +106 -0
  245. package/test/autonomous-r34-e2e.test.mjs +338 -0
  246. package/test/autonomous-runtime.test.mjs +3 -3
  247. package/test/autonomous-supervisor-integration.test.mjs +48 -3
  248. package/test/capability-benchmark-runner.test.mjs +49 -0
  249. package/test/capability-benchmark.test.mjs +47 -0
  250. package/test/cli-entrypoint.test.mjs +12 -0
  251. package/test/coding-catalog-consistency.test.mjs +24 -0
  252. package/test/coding-plane.test.mjs +3 -3
  253. package/test/context-provenance.test.mjs +61 -0
  254. package/test/controller-r27.test.mjs +4 -3
  255. package/test/controller.test.mjs +52 -0
  256. package/test/core.test.mjs +1 -1
  257. package/test/deferred-slot-operation-behavior.test.mjs +5 -1
  258. package/test/deferred-slot-operation.test.mjs +2 -1
  259. package/test/document-adapter.test.mjs +23 -0
  260. package/test/fixtures/lsp-framed-server.mjs +33 -0
  261. package/test/fixtures/semantic/cpp/compile_commands.json +4 -0
  262. package/test/fixtures/semantic/cpp/lib.cpp +2 -0
  263. package/test/fixtures/semantic/cpp/lib.hpp +2 -0
  264. package/test/fixtures/semantic/cpp/main.cpp +2 -0
  265. package/test/fixtures/semantic/python/lib.py +2 -0
  266. package/test/fixtures/semantic/python/main.py +2 -0
  267. package/test/fixtures/semantic/rust/Cargo.lock +7 -0
  268. package/test/fixtures/semantic/rust/Cargo.toml +8 -0
  269. package/test/fixtures/semantic/rust/src/lib.rs +3 -0
  270. package/test/fixtures/semantic/rust/src/main.rs +5 -0
  271. package/test/fixtures/semantic/rust/src/math.rs +3 -0
  272. package/test/fixtures/semantic/rust/target/.rustc_info.json +1 -0
  273. package/test/fixtures/semantic/rust/target/CACHEDIR.TAG +3 -0
  274. package/test/fixtures/semantic/rust/target/debug/.cargo-lock +0 -0
  275. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/dep-test-lib-semantic_rust +0 -0
  276. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/invoked.timestamp +1 -0
  277. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/test-lib-semantic_rust +1 -0
  278. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/test-lib-semantic_rust.json +1 -0
  279. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/dep-test-bin-semantic_rust_bin +0 -0
  280. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/invoked.timestamp +1 -0
  281. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/test-bin-semantic_rust_bin +1 -0
  282. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/test-bin-semantic_rust_bin.json +1 -0
  283. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/dep-lib-semantic_rust +0 -0
  284. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/invoked.timestamp +1 -0
  285. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/lib-semantic_rust +1 -0
  286. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/lib-semantic_rust.json +1 -0
  287. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/bin-semantic_rust_bin +1 -0
  288. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/bin-semantic_rust_bin.json +1 -0
  289. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/dep-bin-semantic_rust_bin +0 -0
  290. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/invoked.timestamp +1 -0
  291. package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust-4c168fa33c79d09c.rmeta +0 -0
  292. package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust-6212ccd976aa3808.rmeta +0 -0
  293. package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust_bin-5dcd474439c54a26.rmeta +0 -0
  294. package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust_bin-d741378dccdef61c.rmeta +0 -0
  295. package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust-4c168fa33c79d09c.d +5 -0
  296. package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust-6212ccd976aa3808.d +5 -0
  297. package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust_bin-5dcd474439c54a26.d +6 -0
  298. package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust_bin-d741378dccdef61c.d +6 -0
  299. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc-1qb77z00k06rqw4jdkj92spax/dep-graph.bin +0 -0
  300. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc-1qb77z00k06rqw4jdkj92spax/query-cache.bin +0 -0
  301. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc-1qb77z00k06rqw4jdkj92spax/work-products.bin +0 -0
  302. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc.lock +0 -0
  303. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/dep-graph.bin +0 -0
  304. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/metadata.rmeta +0 -0
  305. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/query-cache.bin +0 -0
  306. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/work-products.bin +0 -0
  307. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq.lock +0 -0
  308. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3-cmu3jai030no72y8u9eurrnjj/dep-graph.bin +0 -0
  309. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3-cmu3jai030no72y8u9eurrnjj/query-cache.bin +0 -0
  310. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3-cmu3jai030no72y8u9eurrnjj/work-products.bin +0 -0
  311. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3.lock +0 -0
  312. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt-diy9mqvc2eoiblmhjs3stcgi3/dep-graph.bin +0 -0
  313. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt-diy9mqvc2eoiblmhjs3stcgi3/query-cache.bin +0 -0
  314. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt-diy9mqvc2eoiblmhjs3stcgi3/work-products.bin +0 -0
  315. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt.lock +0 -0
  316. package/test/fixtures/semantic/rust/target/flycheck0/stderr +1 -0
  317. package/test/fixtures/semantic/rust/target/flycheck0/stdout +5 -0
  318. package/test/fixtures/semantic/typescript/lib.ts +3 -0
  319. package/test/fixtures/semantic/typescript/main.ts +2 -0
  320. package/test/fixtures/tool-surface-stdio-server.mjs +14 -0
  321. package/test/helpers/autonomous-r34-fixture.mjs +120 -0
  322. package/test/lsp-stdio-client.test.mjs +72 -0
  323. package/test/multi-file-read.test.mjs +41 -0
  324. package/test/observation-integration.test.mjs +3 -3
  325. package/test/production-docs.test.mjs +48 -0
  326. package/test/prompts-resources.test.mjs +35 -0
  327. package/test/provider-circuit.test.mjs +93 -0
  328. package/test/public-autonomous-ingress-budget.test.mjs +28 -0
  329. package/test/r33-closeout-regression.test.mjs +3 -3
  330. package/test/r33-finalization.test.mjs +19 -16
  331. package/test/release-generation.test.mjs +23 -2
  332. package/test/release-version.test.mjs +24 -17
  333. package/test/remote-r24-catalog.test.mjs +5 -4
  334. package/test/remote-result-journal.test.mjs +58 -0
  335. package/test/remote-session-cli.test.mjs +150 -15
  336. package/test/runtime-self-update.test.mjs +63 -0
  337. package/test/semantic-backend-registry.test.mjs +29 -0
  338. package/test/semantic-code.test.mjs +66 -0
  339. package/test/semantic-lsp-backend.test.mjs +99 -0
  340. package/test/semantic-lsp-config.test.mjs +81 -0
  341. package/test/semantic-lsp-readiness.test.mjs +34 -0
  342. package/test/semantic-lsp-transient-empty.test.mjs +32 -0
  343. package/test/semantic-lsp-transient-null.test.mjs +31 -0
  344. package/test/semantic-multilang.test.mjs +72 -0
  345. package/test/semantic-runtime-routing.test.mjs +32 -0
  346. package/test/semantic-server-config-integration.test.mjs +66 -0
  347. package/test/tool-surface-ledger.test.mjs +59 -0
  348. package/test/tool-surface-snapshot.test.mjs +17 -0
  349. package/test/tracer-bullet.test.mjs +77 -0
@@ -0,0 +1,181 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { canonicalJson } from './canonical-json.mjs';
3
+
4
+ export const AUTONOMOUS_PLAN_SCHEMA = 'deadbyte.autonomous-plan.v1';
5
+ const PLAN_ID_SCHEMA = 'deadbyte.autonomous-plan-id.v1';
6
+ const HEX64 = /^[0-9a-f]{64}$/;
7
+ const ID = /^[A-Za-z0-9._-]{1,64}$/;
8
+
9
+ function sha256Object(value) {
10
+ return createHash('sha256').update(Buffer.from(canonicalJson(value),'utf8')).digest('hex');
11
+ }
12
+
13
+ function text(value,label,max) {
14
+ if (typeof value !== 'string' || value.length < 1 || value.length > max) throw new Error(`${label} invalid`);
15
+ return value;
16
+ }
17
+
18
+ function id(value,label) {
19
+ if (typeof value !== 'string' || !ID.test(value)) throw new Error(`${label} invalid`);
20
+ return value;
21
+ }
22
+
23
+ function hash(value,label) {
24
+ if (typeof value !== 'string' || !HEX64.test(value)) throw new Error(`${label} invalid`);
25
+ return value;
26
+ }
27
+
28
+ function normalizeEvidence(evidence) {
29
+ if (!Array.isArray(evidence) || evidence.length < 1 || evidence.length > 32) {
30
+ throw new Error('plan step completion evidence required');
31
+ }
32
+ return evidence.map((item,index) => {
33
+ if (!item || typeof item !== 'object' || Array.isArray(item)) throw new Error(`plan evidence ${index} invalid`);
34
+ const keys = Object.keys(item).sort();
35
+ if (canonicalJson(keys) !== canonicalJson(['id','kind','sha256'])) throw new Error(`plan evidence ${index} fields invalid`);
36
+ return {
37
+ kind:id(item.kind,`plan evidence ${index} kind`),
38
+ id:id(item.id,`plan evidence ${index} id`),
39
+ sha256:hash(item.sha256,`plan evidence ${index} sha256`)
40
+ };
41
+ });
42
+ }
43
+
44
+ function normalizeStepIdentity(raw,index) {
45
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) throw new Error(`plan step ${index} invalid`);
46
+ return {
47
+ step_id:id(raw.step_id,`plan step ${index} step_id`),
48
+ intent:text(raw.intent,`plan step ${index} intent`,512)
49
+ };
50
+ }
51
+
52
+ function assertUniqueStepIds(steps) {
53
+ const seen = new Set();
54
+ for (const step of steps) {
55
+ if (seen.has(step.step_id)) throw new Error(`plan step_id '${step.step_id}' duplicated`);
56
+ seen.add(step.step_id);
57
+ }
58
+ }
59
+
60
+ function assertPlan(plan) {
61
+ if (!plan || typeof plan !== 'object' || Array.isArray(plan) || plan.schema !== AUTONOMOUS_PLAN_SCHEMA) {
62
+ throw new Error('autonomous plan schema invalid');
63
+ }
64
+ hash(plan.plan_id,'plan_id');
65
+ if (!Number.isInteger(plan.plan_version) || plan.plan_version < 1) throw new Error('plan_version invalid');
66
+ if (plan.parent_plan_version !== null && (!Number.isInteger(plan.parent_plan_version) || plan.parent_plan_version < 1 || plan.parent_plan_version >= plan.plan_version)) {
67
+ throw new Error('parent_plan_version invalid');
68
+ }
69
+ text(plan.title,'plan title',160);
70
+ hash(plan.reason_sha256,'plan reason_sha256');
71
+ if (!Array.isArray(plan.steps) || plan.steps.length < 1 || plan.steps.length > 24) throw new Error('plan steps invalid');
72
+ assertUniqueStepIds(plan.steps);
73
+ let active = 0;
74
+ let seenMutable = false;
75
+ let seenPending = false;
76
+ for (const [index,step] of plan.steps.entries()) {
77
+ const identity = normalizeStepIdentity(step,index);
78
+ if (identity.step_id !== step.step_id || identity.intent !== step.intent) throw new Error(`plan step ${index} identity invalid`);
79
+ if (!['pending','active','completed'].includes(step.status)) throw new Error(`plan step ${index} status invalid`);
80
+ if (step.status === 'completed') {
81
+ if (seenMutable) throw new Error('plan completed steps must form an immutable prefix');
82
+ normalizeEvidence(step.evidence);
83
+ } else {
84
+ seenMutable = true;
85
+ if (step.evidence !== undefined) throw new Error(`plan step ${index} evidence requires completed status`);
86
+ if (step.status === 'active') {
87
+ if (seenPending || active > 0) throw new Error('plan may have at most one active step before pending suffix');
88
+ active += 1;
89
+ } else {
90
+ seenPending = true;
91
+ }
92
+ }
93
+ }
94
+ const complete = plan.steps.every(step => step.status === 'completed');
95
+ if (!complete && active !== 1) throw new Error('incomplete plan requires exactly one active step');
96
+ if (complete && active !== 0) throw new Error('complete plan cannot have active step');
97
+ return plan;
98
+ }
99
+
100
+ function completedPrefixLength(plan) {
101
+ let count = 0;
102
+ for (const step of plan.steps) {
103
+ if (step.status !== 'completed') break;
104
+ count += 1;
105
+ }
106
+ return count;
107
+ }
108
+
109
+ function normalizeSuffixStep(raw,index,status) {
110
+ const step = normalizeStepIdentity(raw,index);
111
+ if (raw.evidence !== undefined) throw new Error(`replan suffix step '${step.step_id}' cannot carry completion evidence`);
112
+ return { ...step, status };
113
+ }
114
+
115
+ export function createPlan({ goalId, title, steps, reasonHash }) {
116
+ hash(goalId,'goalId');
117
+ text(title,'plan title',160);
118
+ hash(reasonHash,'reasonHash');
119
+ if (!Array.isArray(steps) || steps.length < 1 || steps.length > 24) throw new Error('plan steps invalid');
120
+ const normalized = steps.map((step,index) => ({ ...normalizeStepIdentity(step,index), status:index === 0 ? 'active' : 'pending' }));
121
+ assertUniqueStepIds(normalized);
122
+ return assertPlan({
123
+ schema:AUTONOMOUS_PLAN_SCHEMA,
124
+ plan_id:sha256Object({ schema:PLAN_ID_SCHEMA, goal_id:goalId }),
125
+ plan_version:1,
126
+ parent_plan_version:null,
127
+ title,
128
+ steps:normalized,
129
+ reason_sha256:reasonHash
130
+ });
131
+ }
132
+
133
+ export function replanPlan(previous,{ steps, reasonHash }) {
134
+ assertPlan(previous);
135
+ hash(reasonHash,'reasonHash');
136
+ if (!Array.isArray(steps) || steps.length < 1 || steps.length > 24) throw new Error('replan steps invalid');
137
+ const locked = completedPrefixLength(previous);
138
+ if (steps.length < locked) throw new Error('replan cannot remove completed prefix');
139
+ for (let index = 0; index < locked; index += 1) {
140
+ if (canonicalJson(steps[index]) !== canonicalJson(previous.steps[index])) {
141
+ throw new Error(`replan cannot modify completed prefix step '${previous.steps[index].step_id}'`);
142
+ }
143
+ }
144
+ if (steps.length === locked) throw new Error('replan requires an active or pending suffix');
145
+ const completed = previous.steps.slice(0,locked).map(step => structuredClone(step));
146
+ const suffix = steps.slice(locked).map((step,index) => normalizeSuffixStep(step,locked + index,index === 0 ? 'active' : 'pending'));
147
+ const combined = [...completed,...suffix];
148
+ assertUniqueStepIds(combined);
149
+ return assertPlan({
150
+ schema:AUTONOMOUS_PLAN_SCHEMA,
151
+ plan_id:previous.plan_id,
152
+ plan_version:previous.plan_version + 1,
153
+ parent_plan_version:previous.plan_version,
154
+ title:previous.title,
155
+ steps:combined,
156
+ reason_sha256:reasonHash
157
+ });
158
+ }
159
+
160
+ export function completePlanStep(previous,{ stepId, evidence }) {
161
+ assertPlan(previous);
162
+ id(stepId,'stepId');
163
+ const activeIndex = previous.steps.findIndex(step => step.status === 'active');
164
+ if (activeIndex < 0) throw new Error('plan has no active step to complete');
165
+ if (previous.steps[activeIndex].step_id !== stepId) throw new Error(`plan step '${stepId}' is not active`);
166
+ const checkedEvidence = normalizeEvidence(evidence);
167
+ const steps = previous.steps.map(step => structuredClone(step));
168
+ steps[activeIndex] = { ...steps[activeIndex], status:'completed', evidence:checkedEvidence };
169
+ if (activeIndex + 1 < steps.length) steps[activeIndex + 1] = { ...steps[activeIndex + 1], status:'active' };
170
+ return assertPlan({ ...previous, steps });
171
+ }
172
+
173
+ export function planIsComplete(plan) {
174
+ assertPlan(plan);
175
+ return plan.steps.every(step => step.status === 'completed');
176
+ }
177
+
178
+ export function activePlanStep(plan) {
179
+ assertPlan(plan);
180
+ return plan.steps.find(step => step.status === 'active') ?? null;
181
+ }
@@ -71,3 +71,47 @@ export function parseStrictJsonText(schema, text, label) {
71
71
  if (!checked.success) throw new Error(`${label} response contract mismatch`);
72
72
  return checked.data;
73
73
  }
74
+
75
+ const r34PlanStepSchema = z.strictObject({
76
+ step_id:z.string().regex(ID),
77
+ intent:z.string().min(1).max(512)
78
+ });
79
+ const r34EvidenceSchema = z.strictObject({
80
+ kind:z.string().regex(ID),
81
+ id:z.string().regex(ID),
82
+ sha256:z.string().regex(HEX64)
83
+ });
84
+ const r34PatchOperationSchema = z.discriminatedUnion('kind',[
85
+ z.strictObject({kind:z.literal('write'),path:relPath,content:z.string().max(524288),
86
+ encoding:z.enum(['utf8','base64']).default('utf8'),expected_sha256:z.string().regex(/^(?:absent|[0-9a-f]{64})$/)}),
87
+ z.strictObject({kind:z.literal('replace'),path:relPath,old_string:z.string().min(1).max(262144),
88
+ new_string:z.string().max(524288),expected_sha256:z.string().regex(HEX64),
89
+ expected_replacements:z.number().int().min(1).max(64).default(1)}),
90
+ z.strictObject({kind:z.literal('delete'),path:relPath,expected_sha256:z.string().regex(HEX64)})
91
+ ]);
92
+ const r34ActionSchema = z.discriminatedUnion('kind',[
93
+ z.strictObject({kind:z.literal('patch'),operations:z.array(r34PatchOperationSchema).min(1).max(32)}),
94
+ z.strictObject({kind:z.literal('run_profile'),profile_id:z.string().regex(ID)}),
95
+ z.strictObject({kind:z.literal('delegate'),operation:z.record(z.string(),z.json())})
96
+ ]);
97
+ const r34ReadSchema = z.strictObject({
98
+ path:relPath,
99
+ max_bytes:z.number().int().min(1).max(262144).default(65536)
100
+ });
101
+
102
+ export const r34PlannerDecisionSchema = z.discriminatedUnion('kind',[
103
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('plan_create'),
104
+ title:z.string().min(1).max(160),reason:z.string().min(1).max(512).optional(),
105
+ steps:z.array(r34PlanStepSchema).min(1).max(24)}),
106
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('inspect'),
107
+ reads:z.array(r34ReadSchema).min(1).max(8)}),
108
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('act'),action:r34ActionSchema}),
109
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('step_complete'),
110
+ step_id:z.string().regex(ID),evidence:z.array(r34EvidenceSchema).min(1).max(32)}),
111
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('replan'),
112
+ reason:z.string().min(1).max(512),steps:z.array(r34PlanStepSchema).min(1).max(24)}),
113
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('pause'),
114
+ reason:z.string().min(1).max(1000)}),
115
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('finish'),
116
+ summary:z.string().min(1).max(1024).optional()})
117
+ ]);
@@ -1,7 +1,11 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import { canonicalJson } from './canonical-json.mjs';
3
+ import { buildLoopContext } from './autonomous-context-engine.mjs';
4
+ import { r34PlannerDecisionSchema } from './autonomous-planner-contracts.mjs';
2
5
  import { validatePortableRelativePath } from './path-policy.mjs';
3
6
 
4
7
  export const AUTONOMOUS_DECISION_SCHEMA = 'deadbyte.autonomous-decision.v1';
8
+ export const AUTONOMOUS_R34_DECISION_SCHEMA = 'deadbyte.autonomous-decision.v2';
5
9
  const ID_RE = /^[A-Za-z0-9._-]{1,64}$/;
6
10
  const SHA256_RE = /^[0-9a-f]{64}$/;
7
11
  function strictKeys(value, allowed, label) {
@@ -178,6 +182,73 @@ export function parsePlannerDecision(rawText, policy) {
178
182
  if (raw.action === 'pause') return withPlan({ schema:AUTONOMOUS_DECISION_SCHEMA, action:'pause', summary, reason:text(raw.reason ?? 'planner_pause','planner pause reason',512,1) });
179
183
  throw new Error('planner action invalid');
180
184
  }
185
+ function assertR34UniqueSteps(steps,label) {
186
+ const seen = new Set();
187
+ for (const step of steps) {
188
+ if (seen.has(step.step_id)) throw new Error(`${label} duplicate step_id '${step.step_id}'`);
189
+ seen.add(step.step_id);
190
+ }
191
+ }
192
+
193
+ export function parseR34PlannerDecision(rawText, policy) {
194
+ if (typeof rawText !== 'string' || rawText.length < 2 || rawText.length > policy.limits.max_context_bytes) {
195
+ throw new Error('R34 planner structured response size invalid');
196
+ }
197
+ const trimmed = rawText.trim();
198
+ if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) {
199
+ throw new Error('R34 planner structured response must be one raw JSON object');
200
+ }
201
+ let raw;
202
+ try { raw = JSON.parse(trimmed); }
203
+ catch (error) { throw new Error(`R34 planner JSON invalid: ${error.message}`); }
204
+ const checked = r34PlannerDecisionSchema.safeParse(raw);
205
+ if (!checked.success) throw new Error('R34 planner decision contract mismatch');
206
+ const decision = checked.data;
207
+ if (decision.schema !== AUTONOMOUS_R34_DECISION_SCHEMA) throw new Error('R34 planner decision schema mismatch');
208
+
209
+ if (decision.kind === 'plan_create') {
210
+ assertR34UniqueSteps(decision.steps,'R34 plan_create');
211
+ return decision;
212
+ }
213
+ if (decision.kind === 'inspect') {
214
+ return { ...decision, reads:decision.reads.map(item => {
215
+ validatePortableRelativePath(item.path);
216
+ return { path:item.path, max_bytes:item.max_bytes };
217
+ }) };
218
+ }
219
+ if (decision.kind === 'act') {
220
+ if (decision.action.kind === 'patch') {
221
+ if (decision.action.operations.length > policy.limits.max_files_per_diff) throw new Error('R34 patch operation count exceeds policy');
222
+ return { ...decision, action:{ kind:'patch', operations:decision.action.operations.map(normalizeOperation) } };
223
+ }
224
+ if (decision.action.kind === 'run_profile') {
225
+ if (!policy.profiles?.[decision.action.profile_id]) throw new Error('R34 planner profile_id invalid');
226
+ return decision;
227
+ }
228
+ if (decision.action.kind === 'delegate') {
229
+ return { ...decision, action:{ kind:'delegate', operation:normalizeDelegatedOperation(decision.action.operation) } };
230
+ }
231
+ throw new Error('R34 planner authority or unsupported action');
232
+ }
233
+ if (decision.kind === 'step_complete') return decision;
234
+ if (decision.kind === 'replan') {
235
+ assertR34UniqueSteps(decision.steps,'R34 replan');
236
+ return decision;
237
+ }
238
+ if (decision.kind === 'pause' || decision.kind === 'finish') return decision;
239
+ throw new Error('R34 planner decision kind unsupported');
240
+ }
241
+
242
+ export async function requestR34ProviderDecision(policy,prompt,fetchImpl = fetch) {
243
+ const response = await requestProviderDecision(policy,prompt,fetchImpl);
244
+ return {
245
+ backend:response.backend,
246
+ model:response.model,
247
+ raw_response_sha256:createHash('sha256').update(Buffer.from(response.raw_text,'utf8')).digest('hex'),
248
+ decision:parseR34PlannerDecision(response.raw_text,policy)
249
+ };
250
+ }
251
+
181
252
  function plannerStateBytes(state) {
182
253
  return Buffer.byteLength(canonicalJson(state),'utf8');
183
254
  }
@@ -223,12 +294,26 @@ function compactPlannerState(state, limit) {
223
294
  return candidate;
224
295
  }
225
296
  export function buildPlannerPrompt({ goal, policy, view }) {
226
- const profiles = Object.entries(policy.profiles).map(([id,p]) => ({ id, kind:p.kind,
227
- required_for_release:p.required_for_release, description:p.description }));
228
- let state = { goal, mutation_epoch:view.mutation_epoch, planner_round:view.planner_round,
229
- tree:view.tree ?? [], contexts:view.contexts ?? [], observations:view.observations ?? [],
230
- active_plan:view.active_plan ?? null, recent_decisions:view.recent_decisions ?? [], profiles };
231
- state = compactPlannerState(state,policy.limits.max_context_bytes);
297
+ const state = buildLoopContext({
298
+ goal,
299
+ policy,
300
+ loopState:{
301
+ phase:view.loop?.phase ?? null,
302
+ mutation_epoch:Number.isInteger(view.mutation_epoch) ? view.mutation_epoch : (view.loop?.mutation_epoch ?? 0),
303
+ planner_round:Number.isInteger(view.planner_round) ? view.planner_round : (view.loop?.planner_round ?? 0),
304
+ plan:view.loop?.plan ?? view.active_plan ?? null,
305
+ active_plan:view.active_plan ?? view.loop?.plan ?? null,
306
+ current_step:view.loop?.current_step ?? null,
307
+ plan_id:view.loop?.plan_id ?? null,
308
+ plan_version:view.loop?.plan_version ?? null,
309
+ replan_count:view.loop?.replan_count ?? 0
310
+ },
311
+ tree:view.tree ?? [],
312
+ contexts:view.contexts ?? [],
313
+ observations:view.observations ?? [],
314
+ decisions:view.recent_decisions ?? [],
315
+ projectMemory:view.project_memory ?? null
316
+ });
232
317
  const stateJson = canonicalJson(state);
233
318
  return [
234
319
  'You are the DEADBYTE R24 autonomous coding planner.',
@@ -21,6 +21,15 @@ function finite(value, name, min, max, fallback) {
21
21
  if (!Number.isFinite(n) || n < min || n > max) throw new Error(`${name} must be in [${min}, ${max}]`);
22
22
  return n;
23
23
  }
24
+ function normalizeProviderCircuit(raw) {
25
+ const value=raw ?? {};
26
+ if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('planner.circuit invalid');
27
+ return Object.freeze({
28
+ failure_threshold:integer(value.failure_threshold,'planner.circuit.failure_threshold',1,32,3),
29
+ open_ms:integer(value.open_ms,'planner.circuit.open_ms',100,3_600_000,30_000),
30
+ half_open_probe_limit:integer(value.half_open_probe_limit,'planner.circuit.half_open_probe_limit',1,8,1)
31
+ });
32
+ }
24
33
  function normalizePlanner(raw) {
25
34
  if (!raw || typeof raw !== 'object' || Array.isArray(raw)) throw new Error('autonomous planner missing');
26
35
  const backend = raw.backend;
@@ -40,7 +49,8 @@ function normalizePlanner(raw) {
40
49
  return {
41
50
  ...common, endpoint: endpoint.toString(), model: raw.model, api_key_env: apiKeyEnv,
42
51
  timeout_ms: integer(raw.timeout_ms, 'planner.timeout_ms', 1000, 300000, 60000),
43
- max_response_bytes: integer(raw.max_response_bytes, 'planner.max_response_bytes', 4096, 2 * 1024 * 1024, 512 * 1024)
52
+ max_response_bytes: integer(raw.max_response_bytes, 'planner.max_response_bytes', 4096, 2 * 1024 * 1024, 512 * 1024),
53
+ circuit:normalizeProviderCircuit(raw.circuit)
44
54
  };
45
55
  }
46
56
  function normalizeProfile(id, raw, codingPolicy) {
@@ -106,7 +116,10 @@ export async function loadAutonomousPolicy(policyPath, codingPolicy) {
106
116
  max_wall_ms: limits.max_wall_ms === null ? null : integer(limits.max_wall_ms, 'limits.max_wall_ms', 60000, 14_400_000, 1_800_000),
107
117
  max_context_bytes: integer(limits.max_context_bytes, 'limits.max_context_bytes', 65536, 8 * 1024 * 1024, 1024 * 1024),
108
118
  max_diff_bytes: integer(limits.max_diff_bytes, 'limits.max_diff_bytes', 65536, 8 * 1024 * 1024, 1024 * 1024),
109
- max_files_per_diff: integer(limits.max_files_per_diff, 'limits.max_files_per_diff', 1, 32, 8)
119
+ max_files_per_diff: integer(limits.max_files_per_diff, 'limits.max_files_per_diff', 1, 32, 8),
120
+ max_stalled_cycles: integer(limits.max_stalled_cycles, 'limits.max_stalled_cycles', 1, 32, 2),
121
+ max_post_replan_stalls: integer(limits.max_post_replan_stalls, 'limits.max_post_replan_stalls', 1, 32, 2),
122
+ max_replans: integer(limits.max_replans, 'limits.max_replans', 1, 32, 8)
110
123
  }
111
124
  };
112
125
  policy.policy_sha256 = sha256Bytes(bytes);
@@ -0,0 +1,127 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { canonicalJson } from './canonical-json.mjs';
3
+
4
+ const POSITIVE_REASONS = Object.freeze([
5
+ 'new_source_identity',
6
+ 'new_profile_evidence',
7
+ 'verified_mutation_epoch_advanced',
8
+ 'acceptance_failure_resolved',
9
+ 'plan_step_completed',
10
+ 'diagnostic_narrowed',
11
+ 'interrupted_action_recovered',
12
+ 'release_readiness_improved'
13
+ ]);
14
+
15
+ const STALL_REASONS = Object.freeze([
16
+ 'equivalent_decision_no_new_evidence',
17
+ 'identical_read_repeated',
18
+ 'identical_profile_failure_repeated',
19
+ 'equivalent_replan',
20
+ 'plan_oscillation'
21
+ ]);
22
+
23
+ function sha256Object(value) {
24
+ return createHash('sha256').update(Buffer.from(canonicalJson(value),'utf8')).digest('hex');
25
+ }
26
+
27
+ function stripPlannerText(value) {
28
+ if (Array.isArray(value)) return value.map(stripPlannerText);
29
+ if (!value || typeof value !== 'object') return value;
30
+ const out = {};
31
+ for (const [key,item] of Object.entries(value)) {
32
+ if (['rationale','summary','explanation','planner_reason'].includes(key)) continue;
33
+ out[key] = stripPlannerText(item);
34
+ }
35
+ return out;
36
+ }
37
+
38
+ function finiteNumber(value,fallback = 0) {
39
+ return Number.isFinite(value) ? value : fallback;
40
+ }
41
+
42
+ function add(reasons,reason,condition) {
43
+ if (condition && !reasons.includes(reason)) reasons.push(reason);
44
+ }
45
+
46
+ export function judgeProgress({ before = {}, after = {}, decision = {}, evidence = {} } = {}) {
47
+ const positive = [];
48
+ const stalled = [];
49
+ const regressed = [];
50
+
51
+ add(positive,'new_source_identity',evidence.new_source_identity === true ||
52
+ (typeof before.source_sha256 === 'string' && typeof after.source_sha256 === 'string' && before.source_sha256 !== after.source_sha256));
53
+ add(positive,'new_profile_evidence',evidence.new_profile_evidence === true);
54
+ add(positive,'verified_mutation_epoch_advanced',evidence.native_diff_verified === true &&
55
+ Number.isInteger(before.mutation_epoch) && Number.isInteger(after.mutation_epoch) && after.mutation_epoch > before.mutation_epoch);
56
+ add(positive,'acceptance_failure_resolved',finiteNumber(before.acceptance_failures) > finiteNumber(after.acceptance_failures));
57
+ add(positive,'plan_step_completed',evidence.step_evidence_verified === true &&
58
+ finiteNumber(after.completed_steps) > finiteNumber(before.completed_steps));
59
+ add(positive,'diagnostic_narrowed',evidence.diagnostic_narrowed === true);
60
+ add(positive,'interrupted_action_recovered',evidence.interrupted_action_recovered === true);
61
+ add(positive,'release_readiness_improved',evidence.release_readiness_improved === true ||
62
+ (before.release_ready === false && after.release_ready === true));
63
+
64
+ add(stalled,'equivalent_decision_no_new_evidence',evidence.equivalent_decision === true);
65
+ add(stalled,'identical_read_repeated',evidence.same_source_sha === true);
66
+ add(stalled,'identical_profile_failure_repeated',evidence.identical_profile_failure === true);
67
+ add(stalled,'equivalent_replan',evidence.equivalent_replan === true);
68
+ add(stalled,'plan_oscillation',evidence.plan_oscillation === true);
69
+
70
+ add(regressed,'acceptance_failures_increased',finiteNumber(after.acceptance_failures) > finiteNumber(before.acceptance_failures));
71
+ add(regressed,'release_readiness_regressed',before.release_ready === true && after.release_ready === false);
72
+
73
+ let verdict = 'stalled';
74
+ let score = 0;
75
+ let reasonCodes;
76
+ if (positive.length > 0) {
77
+ verdict = 'progress';
78
+ score = positive.length;
79
+ reasonCodes = positive;
80
+ } else if (regressed.length > 0) {
81
+ verdict = 'regressed';
82
+ score = -regressed.length;
83
+ reasonCodes = regressed;
84
+ } else {
85
+ reasonCodes = stalled.length > 0 ? stalled : ['no_machine_progress_signal'];
86
+ }
87
+
88
+ const fingerprint = sha256Object({
89
+ before:stripPlannerText(before),
90
+ after:stripPlannerText(after),
91
+ decision:stripPlannerText(decision),
92
+ evidence:stripPlannerText(evidence),
93
+ verdict,
94
+ reason_codes:reasonCodes
95
+ });
96
+
97
+ return Object.freeze({ verdict, score, reason_codes:Object.freeze([...reasonCodes]), fingerprint });
98
+ }
99
+
100
+ function integerLimit(limits,name) {
101
+ const value = limits?.[name];
102
+ if (!Number.isInteger(value) || value < 1 || value > 32) throw new Error(`progress ${name} invalid`);
103
+ return value;
104
+ }
105
+
106
+ export function stallDisposition({ history = [], limits } = {}) {
107
+ if (!Array.isArray(history)) throw new Error('progress history must be an array');
108
+ const maxStalled = integerLimit(limits,'max_stalled_cycles');
109
+ const maxPostReplan = integerLimit(limits,'max_post_replan_stalls');
110
+ const maxReplans = integerLimit(limits,'max_replans');
111
+ const replanCount = history.filter(item => item === 'replan').length;
112
+ if (replanCount >= maxReplans) return { action:'wait', reason:'replan_limit_reached' };
113
+
114
+ let trailingStalls = 0;
115
+ for (let index = history.length - 1; index >= 0 && history[index] === 'stalled'; index -= 1) trailingStalls += 1;
116
+ const lastReplan = history.lastIndexOf('replan');
117
+ if (lastReplan >= 0 && trailingStalls >= maxPostReplan) {
118
+ return { action:'wait', reason:'post_replan_stall_threshold_reached' };
119
+ }
120
+ if (lastReplan < 0 && trailingStalls >= maxStalled) {
121
+ return { action:'replan', reason:'stall_threshold_reached' };
122
+ }
123
+ return { action:'continue', reason:'within_progress_budget' };
124
+ }
125
+
126
+ export const AUTONOMOUS_PROGRESS_POSITIVE_REASONS = POSITIVE_REASONS;
127
+ export const AUTONOMOUS_PROGRESS_STALL_REASONS = STALL_REASONS;