deadbyte-mcp 0.8.10 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/CONTEXT.md +41 -0
  2. package/MANIFEST.SHA256 +386 -94
  3. package/R34-BASELINE.json +9 -0
  4. package/README.txt +141 -10
  5. package/bench/fixtures/corpus.json +36 -0
  6. package/bench/fixtures/r36/case-map.json +8 -0
  7. package/bin/WORKER-REGISTRY.txt +3 -3
  8. package/bin/appcontainer-stage.exe +0 -0
  9. package/bin/appcontainer-stage.obj +0 -0
  10. package/bin/bootstrap-advapi32.exe +0 -0
  11. package/bin/bootstrap-advapi32.obj +0 -0
  12. package/bin/bootstrap-exitcode.exe +0 -0
  13. package/bin/bootstrap-exitcode.obj +0 -0
  14. package/bin/bootstrap-kernel32.exe +0 -0
  15. package/bin/bootstrap-kernel32.obj +0 -0
  16. package/bin/child-control-probe.exe +0 -0
  17. package/bin/child-control-probe.obj +0 -0
  18. package/bin/child-control-stage.exe +0 -0
  19. package/bin/child-control-stage.obj +0 -0
  20. package/bin/contained-reverse-worker.exe +0 -0
  21. package/bin/contained-reverse-worker.obj +0 -0
  22. package/bin/contained-transform-worker.exe +0 -0
  23. package/bin/contained-transform-worker.obj +0 -0
  24. package/bin/containment-probe.exe +0 -0
  25. package/bin/containment-probe.obj +0 -0
  26. package/bin/deadbyte-contain.exe +0 -0
  27. package/bin/deadbyte-contain.obj +0 -0
  28. package/bin/deadbyte-exec.exe +0 -0
  29. package/bin/deadbyte-exec.obj +0 -0
  30. package/bin/deadbyte-process-host.exe +0 -0
  31. package/bin/deadbyte-process-host.obj +0 -0
  32. package/bin/deadbyte-tunnel-host.exe +0 -0
  33. package/bin/deadbyte-tunnel-host.obj +0 -0
  34. package/controller/README.TXT +12 -4
  35. package/controller/deadbyte-controller.config.psd1.example +14 -0
  36. package/controller/deadbyte-controller.ps1 +191 -20
  37. package/controller/deadbyte-process-policy.json +5 -5
  38. package/controller/deadbyte-semantic-lsp-config.json +95 -0
  39. package/docs/ADR-0001-PRODUCTION-BASELINE-SEAMS.md +29 -0
  40. package/docs/ARCHITECTURE.md +6 -5
  41. package/docs/R36-CAPABILITY-EVIDENCE.md +43 -0
  42. package/docs/superpowers/plans/2026-09-16-deadbyte-loop-engine.md +846 -0
  43. package/docs/superpowers/plans/2026-09-17-r35-production-successor.md +408 -0
  44. package/docs/superpowers/plans/2026-09-18-r36-zero-loss-autonomy.md +739 -0
  45. package/docs/superpowers/specs/2026-09-16-deadbyte-loop-engine-design.md +435 -0
  46. package/docs/superpowers/specs/2026-09-17-r35-production-successor-design.md +220 -0
  47. package/docs/superpowers/specs/2026-09-18-r36-zero-loss-autonomy-design.md +640 -0
  48. package/node_modules/typescript/LICENSE.txt +55 -0
  49. package/node_modules/typescript/README.md +50 -0
  50. package/node_modules/typescript/SECURITY.md +41 -0
  51. package/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  52. package/node_modules/typescript/bin/tsc +2 -0
  53. package/node_modules/typescript/bin/tsserver +2 -0
  54. package/node_modules/typescript/lib/_tsc.js +133818 -0
  55. package/node_modules/typescript/lib/_tsserver.js +659 -0
  56. package/node_modules/typescript/lib/_typingsInstaller.js +222 -0
  57. package/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
  58. package/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
  59. package/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
  60. package/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
  61. package/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
  62. package/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
  63. package/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
  64. package/node_modules/typescript/lib/lib.d.ts +22 -0
  65. package/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
  66. package/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
  67. package/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
  68. package/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
  69. package/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
  70. package/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
  71. package/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
  72. package/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
  73. package/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
  74. package/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
  75. package/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
  76. package/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
  77. package/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
  78. package/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
  79. package/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
  80. package/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
  81. package/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
  82. package/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
  83. package/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
  84. package/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
  85. package/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
  86. package/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
  87. package/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
  88. package/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
  89. package/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
  90. package/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
  91. package/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
  92. package/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
  93. package/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
  94. package/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
  95. package/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
  96. package/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
  97. package/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
  98. package/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
  99. package/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
  100. package/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
  101. package/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
  102. package/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
  103. package/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
  104. package/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
  105. package/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
  106. package/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
  107. package/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
  108. package/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
  109. package/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
  110. package/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
  111. package/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
  112. package/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
  113. package/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
  114. package/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
  115. package/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
  116. package/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
  117. package/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
  118. package/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
  119. package/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
  120. package/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
  121. package/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
  122. package/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
  123. package/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
  124. package/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
  125. package/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
  126. package/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
  127. package/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
  128. package/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
  129. package/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
  130. package/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
  131. package/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
  132. package/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
  133. package/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
  134. package/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
  135. package/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
  136. package/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
  137. package/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
  138. package/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
  139. package/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
  140. package/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
  141. package/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
  142. package/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
  143. package/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
  144. package/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
  145. package/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
  146. package/node_modules/typescript/lib/lib.es6.d.ts +23 -0
  147. package/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
  148. package/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
  149. package/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
  150. package/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
  151. package/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
  152. package/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
  153. package/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
  154. package/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
  155. package/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
  156. package/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
  157. package/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
  158. package/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
  159. package/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
  160. package/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
  161. package/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
  162. package/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
  163. package/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
  164. package/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
  165. package/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
  166. package/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
  167. package/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
  168. package/node_modules/typescript/lib/tsc.js +8 -0
  169. package/node_modules/typescript/lib/tsserver.js +8 -0
  170. package/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
  171. package/node_modules/typescript/lib/tsserverlibrary.js +21 -0
  172. package/node_modules/typescript/lib/typesMap.json +497 -0
  173. package/node_modules/typescript/lib/typescript.d.ts +11437 -0
  174. package/node_modules/typescript/lib/typescript.js +200276 -0
  175. package/node_modules/typescript/lib/typingsInstaller.js +8 -0
  176. package/node_modules/typescript/lib/watchGuard.js +53 -0
  177. package/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
  178. package/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
  179. package/node_modules/typescript/package.json +120 -0
  180. package/package.json +5 -3
  181. package/proof/CONTAINMENT-BUILD.txt +6 -6
  182. package/proof/R34-TASK8-SUPERVISOR-CHECKPOINT.json +29 -0
  183. package/proof/R34-TASK9-MCP-SURFACE-CHECKPOINT.json +28 -0
  184. package/scripts/capability-benchmark.mjs +27 -0
  185. package/scripts/deferred-slot-operation.mjs +56 -16
  186. package/scripts/final-closure-verify.mjs +88 -39
  187. package/scripts/final-closure.mjs +63 -56
  188. package/scripts/gate-windows.ps1 +3 -3
  189. package/scripts/release-parity-tests.ps1 +9 -0
  190. package/scripts/release-parity.mjs +149 -139
  191. package/scripts/semantic-preflight.ps1 +73 -0
  192. package/scripts/tool-surface-snapshot.mjs +73 -0
  193. package/scripts/windows-gate-evidence.mjs +5 -5
  194. package/src/audit-verify.mjs +6 -2
  195. package/src/autonomous-action-reconcile.mjs +142 -0
  196. package/src/autonomous-context-engine.mjs +256 -0
  197. package/src/autonomous-live-state.mjs +17 -0
  198. package/src/autonomous-local-supervisor.mjs +249 -0
  199. package/src/autonomous-loop-state.mjs +304 -0
  200. package/src/autonomous-mcp-tools.mjs +5 -1
  201. package/src/autonomous-output-contracts.mjs +26 -7
  202. package/src/autonomous-plan.mjs +181 -0
  203. package/src/autonomous-planner-contracts.mjs +79 -0
  204. package/src/autonomous-planner.mjs +113 -6
  205. package/src/autonomous-policy.mjs +15 -2
  206. package/src/autonomous-progress.mjs +127 -0
  207. package/src/autonomous-runtime.mjs +785 -62
  208. package/src/autonomous-supervisor-host.mjs +70 -0
  209. package/src/autonomous-supervisor.mjs +31 -8
  210. package/src/capability-benchmark-runner.mjs +193 -0
  211. package/src/capability-benchmark.mjs +95 -0
  212. package/src/capability-ledger.mjs +158 -0
  213. package/src/coding-mcp-tools.mjs +65 -8
  214. package/src/coding-output-contracts.mjs +91 -8
  215. package/src/coding-plane.mjs +45 -9
  216. package/src/coding-search.mjs +130 -47
  217. package/src/compact-gateway-mcp-tools.mjs +128 -0
  218. package/src/compact-gateway-output-contracts.mjs +16 -0
  219. package/src/context-provenance.mjs +86 -0
  220. package/src/deadbyte-cli.mjs +145 -30
  221. package/src/document-adapter.mjs +43 -0
  222. package/src/lsp-stdio-client.mjs +112 -0
  223. package/src/machine-fs-smoke-client.mjs +2 -1
  224. package/src/machine-fs.mjs +51 -8
  225. package/src/mcp-server.mjs +46 -9
  226. package/src/native-diff-v2.mjs +337 -0
  227. package/src/native-diff.mjs +50 -2
  228. package/src/observation-smoke-client.mjs +3 -2
  229. package/src/operator-surface.mjs +43 -0
  230. package/src/process-runtime.mjs +98 -11
  231. package/src/process-smoke-client.mjs +11 -3
  232. package/src/provider-circuit.mjs +125 -0
  233. package/src/r36-compact-disarmed-probe.mjs +50 -0
  234. package/src/r36-full-surface-probe.mjs +56 -0
  235. package/src/release-generation.mjs +44 -5
  236. package/src/remote-live-log.mjs +76 -0
  237. package/src/remote-mcp-autonomous-smoke-client.mjs +58 -15
  238. package/src/remote-mcp-coding-smoke-client.mjs +5 -4
  239. package/src/remote-mcp-r24-disarmed-smoke-client.mjs +4 -2
  240. package/src/remote-mcp-r34-parity-client.mjs +177 -0
  241. package/src/remote-mcp-r36-parity-client.mjs +175 -0
  242. package/src/remote-mcp-smoke-client.mjs +113 -56
  243. package/src/remote-result-journal.mjs +114 -0
  244. package/src/runtime-update.mjs +109 -9
  245. package/src/search-cursor.mjs +45 -0
  246. package/src/semantic-backend-registry.mjs +39 -0
  247. package/src/semantic-code.mjs +246 -0
  248. package/src/semantic-lsp-backend.mjs +219 -0
  249. package/src/semantic-lsp-config.mjs +112 -0
  250. package/src/tool-surface-ledger.mjs +92 -0
  251. package/src/version.mjs +1 -1
  252. package/test/audit-verify.test.mjs +1 -1
  253. package/test/autonomous-action-reconcile.test.mjs +106 -0
  254. package/test/autonomous-adversarial.test.mjs +149 -6
  255. package/test/autonomous-capability-r36.test.mjs +151 -0
  256. package/test/autonomous-context-engine.test.mjs +181 -0
  257. package/test/autonomous-live-state.test.mjs +27 -0
  258. package/test/autonomous-local-supervisor.test.mjs +403 -0
  259. package/test/autonomous-loop-state.test.mjs +126 -0
  260. package/test/autonomous-loop-v2.test.mjs +105 -0
  261. package/test/autonomous-loop.test.mjs +79 -1
  262. package/test/autonomous-output-contract.test.mjs +54 -0
  263. package/test/autonomous-plan.test.mjs +101 -0
  264. package/test/autonomous-progress.test.mjs +106 -0
  265. package/test/autonomous-r34-e2e.test.mjs +338 -0
  266. package/test/autonomous-runtime.test.mjs +3 -3
  267. package/test/autonomous-supervisor-integration.test.mjs +48 -3
  268. package/test/capability-benchmark-r36.test.mjs +107 -0
  269. package/test/capability-benchmark-runner.test.mjs +49 -0
  270. package/test/capability-benchmark-semantic-r36.test.mjs +52 -0
  271. package/test/capability-benchmark.test.mjs +47 -0
  272. package/test/capability-claims-r36.test.mjs +23 -0
  273. package/test/capability-ledger-r36.test.mjs +102 -0
  274. package/test/cli-entrypoint.test.mjs +12 -0
  275. package/test/coding-catalog-consistency.test.mjs +24 -0
  276. package/test/coding-plane.test.mjs +3 -3
  277. package/test/coding-runtime.test.mjs +16 -0
  278. package/test/coding-search-r36.test.mjs +90 -0
  279. package/test/compact-catalog-r36.test.mjs +37 -0
  280. package/test/compact-gateway-r36.test.mjs +66 -0
  281. package/test/contained.test.mjs +1 -1
  282. package/test/context-provenance.test.mjs +61 -0
  283. package/test/controller-r27.test.mjs +4 -3
  284. package/test/controller.test.mjs +52 -0
  285. package/test/core.test.mjs +1 -1
  286. package/test/deferred-slot-operation-behavior.test.mjs +5 -1
  287. package/test/deferred-slot-operation.test.mjs +11 -1
  288. package/test/document-adapter.test.mjs +23 -0
  289. package/test/fixtures/lsp-framed-server.mjs +35 -0
  290. package/test/fixtures/semantic/cpp/compile_commands.json +4 -0
  291. package/test/fixtures/semantic/cpp/lib.cpp +2 -0
  292. package/test/fixtures/semantic/cpp/lib.hpp +2 -0
  293. package/test/fixtures/semantic/cpp/main.cpp +2 -0
  294. package/test/fixtures/semantic/python/lib.py +2 -0
  295. package/test/fixtures/semantic/python/main.py +2 -0
  296. package/test/fixtures/semantic/rust/Cargo.lock +7 -0
  297. package/test/fixtures/semantic/rust/Cargo.toml +8 -0
  298. package/test/fixtures/semantic/rust/src/lib.rs +3 -0
  299. package/test/fixtures/semantic/rust/src/main.rs +5 -0
  300. package/test/fixtures/semantic/rust/src/math.rs +3 -0
  301. package/test/fixtures/semantic/rust/target/.rustc_info.json +1 -0
  302. package/test/fixtures/semantic/rust/target/CACHEDIR.TAG +3 -0
  303. package/test/fixtures/semantic/rust/target/debug/.cargo-lock +0 -0
  304. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/dep-test-lib-semantic_rust +0 -0
  305. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/invoked.timestamp +1 -0
  306. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/test-lib-semantic_rust +1 -0
  307. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-4c168fa33c79d09c/test-lib-semantic_rust.json +1 -0
  308. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/dep-test-bin-semantic_rust_bin +0 -0
  309. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/invoked.timestamp +1 -0
  310. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/test-bin-semantic_rust_bin +1 -0
  311. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-5dcd474439c54a26/test-bin-semantic_rust_bin.json +1 -0
  312. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/dep-lib-semantic_rust +0 -0
  313. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/invoked.timestamp +1 -0
  314. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/lib-semantic_rust +1 -0
  315. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-6212ccd976aa3808/lib-semantic_rust.json +1 -0
  316. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/bin-semantic_rust_bin +1 -0
  317. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/bin-semantic_rust_bin.json +1 -0
  318. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/dep-bin-semantic_rust_bin +0 -0
  319. package/test/fixtures/semantic/rust/target/debug/.fingerprint/semantic_rust-d741378dccdef61c/invoked.timestamp +1 -0
  320. package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust-4c168fa33c79d09c.rmeta +0 -0
  321. package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust-6212ccd976aa3808.rmeta +0 -0
  322. package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust_bin-5dcd474439c54a26.rmeta +0 -0
  323. package/test/fixtures/semantic/rust/target/debug/deps/libsemantic_rust_bin-d741378dccdef61c.rmeta +0 -0
  324. package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust-4c168fa33c79d09c.d +5 -0
  325. package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust-6212ccd976aa3808.d +5 -0
  326. package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust_bin-5dcd474439c54a26.d +6 -0
  327. package/test/fixtures/semantic/rust/target/debug/deps/semantic_rust_bin-d741378dccdef61c.d +6 -0
  328. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc-1qb77z00k06rqw4jdkj92spax/dep-graph.bin +0 -0
  329. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc-1qb77z00k06rqw4jdkj92spax/query-cache.bin +0 -0
  330. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc-1qb77z00k06rqw4jdkj92spax/work-products.bin +0 -0
  331. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-1nzlugxi6lq16/s-hmdgo8b6hg-1n6glhc.lock +0 -0
  332. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/dep-graph.bin +0 -0
  333. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/metadata.rmeta +0 -0
  334. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/query-cache.bin +0 -0
  335. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq-9twkpivsqnjon278x20bddozq/work-products.bin +0 -0
  336. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust-3s436v7g6f5xm/s-hmdgo8b58k-1ekj4lq.lock +0 -0
  337. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3-cmu3jai030no72y8u9eurrnjj/dep-graph.bin +0 -0
  338. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3-cmu3jai030no72y8u9eurrnjj/query-cache.bin +0 -0
  339. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3-cmu3jai030no72y8u9eurrnjj/work-products.bin +0 -0
  340. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-1jxcbdeehal7q/s-hmdgo8bxlf-1qr24o3.lock +0 -0
  341. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt-diy9mqvc2eoiblmhjs3stcgi3/dep-graph.bin +0 -0
  342. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt-diy9mqvc2eoiblmhjs3stcgi3/query-cache.bin +0 -0
  343. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt-diy9mqvc2eoiblmhjs3stcgi3/work-products.bin +0 -0
  344. package/test/fixtures/semantic/rust/target/debug/incremental/semantic_rust_bin-2ocx55p60ni6b/s-hmdgo8bxj8-0ir41qt.lock +0 -0
  345. package/test/fixtures/semantic/rust/target/flycheck0/stderr +1 -0
  346. package/test/fixtures/semantic/rust/target/flycheck0/stdout +5 -0
  347. package/test/fixtures/semantic/typescript/lib.ts +3 -0
  348. package/test/fixtures/semantic/typescript/main.ts +2 -0
  349. package/test/fixtures/tool-surface-stdio-server.mjs +14 -0
  350. package/test/helpers/autonomous-r34-fixture.mjs +122 -0
  351. package/test/lsp-stdio-client.test.mjs +72 -0
  352. package/test/multi-file-read.test.mjs +44 -0
  353. package/test/native-diff-topology-r36.test.mjs +105 -0
  354. package/test/observation-integration.test.mjs +3 -3
  355. package/test/package-boundary.test.mjs +6 -0
  356. package/test/process-longrun-r36.test.mjs +82 -0
  357. package/test/process-release-gate.test.mjs +9 -0
  358. package/test/production-docs.test.mjs +48 -0
  359. package/test/prompts-resources.test.mjs +41 -0
  360. package/test/provider-circuit.test.mjs +93 -0
  361. package/test/public-autonomous-ingress-budget.test.mjs +28 -0
  362. package/test/r33-closeout-regression.test.mjs +4 -3
  363. package/test/r33-finalization.test.mjs +26 -18
  364. package/test/r36-finalization.test.mjs +104 -0
  365. package/test/r36-release-identity.test.mjs +52 -0
  366. package/test/release-generation.test.mjs +23 -2
  367. package/test/release-version.test.mjs +27 -17
  368. package/test/remote-live-log-r36.test.mjs +37 -0
  369. package/test/remote-live-log-recovery-r36.test.mjs +41 -0
  370. package/test/remote-r24-catalog.test.mjs +18 -4
  371. package/test/remote-result-journal.test.mjs +58 -0
  372. package/test/remote-session-cli.test.mjs +135 -30
  373. package/test/runtime-self-update.test.mjs +121 -1
  374. package/test/semantic-backend-registry.test.mjs +29 -0
  375. package/test/semantic-code.test.mjs +66 -0
  376. package/test/semantic-lsp-backend.test.mjs +108 -0
  377. package/test/semantic-lsp-config.test.mjs +81 -0
  378. package/test/semantic-lsp-readiness.test.mjs +34 -0
  379. package/test/semantic-lsp-transient-empty.test.mjs +32 -0
  380. package/test/semantic-lsp-transient-null.test.mjs +31 -0
  381. package/test/semantic-multilang.test.mjs +72 -0
  382. package/test/semantic-r36-rename.test.mjs +82 -0
  383. package/test/semantic-runtime-routing.test.mjs +32 -0
  384. package/test/semantic-server-config-integration.test.mjs +66 -0
  385. package/test/tool-surface-ledger.test.mjs +59 -0
  386. package/test/tool-surface-snapshot.test.mjs +17 -0
  387. package/test/tracer-bullet.test.mjs +77 -0
  388. package/deadbyte-mcp-0.8.9.tgz +0 -0
@@ -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) {
@@ -115,6 +119,27 @@ function normalizeDelegatedOperation(raw) {
115
119
  }
116
120
  throw new Error('planner delegated operation kind invalid');
117
121
  }
122
+
123
+ function legacyDelegatedToTyped(operation) {
124
+ if (operation.kind === 'machine_stat') return { kind:'machine_fs_stat', path:operation.path, hash:operation.hash };
125
+ if (operation.kind === 'machine_list') return { kind:'machine_fs_list', path:operation.path, cursor:operation.cursor, limit:operation.limit, hash_files:operation.hash_files };
126
+ if (operation.kind === 'machine_read') return { kind:'machine_fs_read', path:operation.path, offset:operation.offset, max_bytes:operation.max_bytes, hash_file:operation.hash };
127
+ return operation;
128
+ }
129
+ function validateR36TypedAction(action) {
130
+ const pathFields=[];
131
+ if (typeof action.path === 'string' && action.path !== '.') pathFields.push(action.path);
132
+ if (typeof action.cwd === 'string' && action.cwd !== '.') pathFields.push(action.cwd);
133
+ if (typeof action.source_path === 'string') pathFields.push(action.source_path);
134
+ if (typeof action.destination_path === 'string') pathFields.push(action.destination_path);
135
+ for (const item of action.files ?? []) if (typeof item?.path === 'string') pathFields.push(item.path);
136
+ for (const candidate of pathFields) validatePortableRelativePath(candidate);
137
+ return action;
138
+ }
139
+ function normalizeR36TypedAction(action) {
140
+ if (action.kind === 'delegate') return validateR36TypedAction(legacyDelegatedToTyped(normalizeDelegatedOperation(action.operation)));
141
+ return validateR36TypedAction(action);
142
+ }
118
143
  function normalizePlan(raw) {
119
144
  strictKeys(raw, ['title','reason','steps'], 'planner plan');
120
145
  const title = text(raw.title, 'planner plan title', 160, 1);
@@ -178,6 +203,73 @@ export function parsePlannerDecision(rawText, policy) {
178
203
  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
204
  throw new Error('planner action invalid');
180
205
  }
206
+ function assertR34UniqueSteps(steps,label) {
207
+ const seen = new Set();
208
+ for (const step of steps) {
209
+ if (seen.has(step.step_id)) throw new Error(`${label} duplicate step_id '${step.step_id}'`);
210
+ seen.add(step.step_id);
211
+ }
212
+ }
213
+
214
+ export function parseR34PlannerDecision(rawText, policy) {
215
+ if (typeof rawText !== 'string' || rawText.length < 2 || rawText.length > policy.limits.max_context_bytes) {
216
+ throw new Error('R34 planner structured response size invalid');
217
+ }
218
+ const trimmed = rawText.trim();
219
+ if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) {
220
+ throw new Error('R34 planner structured response must be one raw JSON object');
221
+ }
222
+ let raw;
223
+ try { raw = JSON.parse(trimmed); }
224
+ catch (error) { throw new Error(`R34 planner JSON invalid: ${error.message}`); }
225
+ const checked = r34PlannerDecisionSchema.safeParse(raw);
226
+ if (!checked.success) throw new Error('R34 planner decision contract mismatch');
227
+ const decision = checked.data;
228
+ if (decision.schema !== AUTONOMOUS_R34_DECISION_SCHEMA) throw new Error('R34 planner decision schema mismatch');
229
+
230
+ if (decision.kind === 'plan_create') {
231
+ assertR34UniqueSteps(decision.steps,'R34 plan_create');
232
+ return decision;
233
+ }
234
+ if (decision.kind === 'inspect') {
235
+ return { ...decision, reads:decision.reads.map(item => {
236
+ validatePortableRelativePath(item.path);
237
+ return { path:item.path, max_bytes:item.max_bytes };
238
+ }) };
239
+ }
240
+ if (decision.kind === 'act') {
241
+ if (decision.action.kind === 'patch') {
242
+ if (decision.action.operations.length > policy.limits.max_files_per_diff) throw new Error('R34 patch operation count exceeds policy');
243
+ return { ...decision, action:{ kind:'patch', operations:decision.action.operations.map(normalizeOperation) } };
244
+ }
245
+ if (decision.action.kind === 'run_profile') {
246
+ if (!policy.profiles?.[decision.action.profile_id]) throw new Error('R34 planner profile_id invalid');
247
+ return decision;
248
+ }
249
+ if (decision.action.kind === 'delegate') {
250
+ return { ...decision, action:normalizeR36TypedAction(decision.action) };
251
+ }
252
+ return { ...decision, action:normalizeR36TypedAction(decision.action) };
253
+ }
254
+ if (decision.kind === 'step_complete') return decision;
255
+ if (decision.kind === 'replan') {
256
+ assertR34UniqueSteps(decision.steps,'R34 replan');
257
+ return decision;
258
+ }
259
+ if (decision.kind === 'pause' || decision.kind === 'finish') return decision;
260
+ throw new Error('R34 planner decision kind unsupported');
261
+ }
262
+
263
+ export async function requestR34ProviderDecision(policy,prompt,fetchImpl = fetch) {
264
+ const response = await requestProviderDecision(policy,prompt,fetchImpl);
265
+ return {
266
+ backend:response.backend,
267
+ model:response.model,
268
+ raw_response_sha256:createHash('sha256').update(Buffer.from(response.raw_text,'utf8')).digest('hex'),
269
+ decision:parseR34PlannerDecision(response.raw_text,policy)
270
+ };
271
+ }
272
+
181
273
  function plannerStateBytes(state) {
182
274
  return Buffer.byteLength(canonicalJson(state),'utf8');
183
275
  }
@@ -223,12 +315,27 @@ function compactPlannerState(state, limit) {
223
315
  return candidate;
224
316
  }
225
317
  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);
318
+ const state = buildLoopContext({
319
+ goal,
320
+ policy,
321
+ loopState:{
322
+ phase:view.loop?.phase ?? null,
323
+ mutation_epoch:Number.isInteger(view.mutation_epoch) ? view.mutation_epoch : (view.loop?.mutation_epoch ?? 0),
324
+ planner_round:Number.isInteger(view.planner_round) ? view.planner_round : (view.loop?.planner_round ?? 0),
325
+ plan:view.loop?.plan ?? view.active_plan ?? null,
326
+ active_plan:view.active_plan ?? view.loop?.plan ?? null,
327
+ current_step:view.loop?.current_step ?? null,
328
+ plan_id:view.loop?.plan_id ?? null,
329
+ plan_version:view.loop?.plan_version ?? null,
330
+ replan_count:view.loop?.replan_count ?? 0
331
+ },
332
+ tree:view.tree ?? [],
333
+ contexts:view.contexts ?? [],
334
+ observations:view.observations ?? [],
335
+ decisions:view.recent_decisions ?? [],
336
+ projectMemory:view.project_memory ?? null,
337
+ capabilities:view.capabilities ?? null
338
+ });
232
339
  const stateJson = canonicalJson(state);
233
340
  return [
234
341
  '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;