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
@@ -0,0 +1,304 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { canonicalJson } from './canonical-json.mjs';
3
+ import { activePlanStep } from './autonomous-plan.mjs';
4
+
5
+ export const AUTONOMOUS_LOOP_STATE_SCHEMA = 'deadbyte.autonomous-loop-state.v2';
6
+ export const AUTONOMOUS_LOOP_PHASES = Object.freeze([
7
+ 'PLAN','INSPECT','ACT','VERIFY','CRITIC','REPAIR','RELEASE','WAITING','SUCCEEDED','FAILED'
8
+ ]);
9
+
10
+ const PHASES = new Set(AUTONOMOUS_LOOP_PHASES);
11
+ const LEGACY_PHASES = new Map([
12
+ ['PLANNING','PLAN'],['INSPECTING','INSPECT'],['ACTING','ACT'],['VERIFYING','VERIFY'],
13
+ ['REPLANNING','REPAIR'],['WAITING','WAITING'],['COMPLETE','SUCCEEDED']
14
+ ]);
15
+ const HEX64 = /^[0-9a-f]{64}$/;
16
+ const ZERO_HASH = '0'.repeat(64);
17
+ const FAILURE_CLASSES = new Set([
18
+ 'verification_failure','stale_precondition','no_progress','insufficient_proof','provider_failure','other'
19
+ ]);
20
+ const MUTABLE_TERMINAL_EVENTS = new Set([
21
+ 'plan_created','plan_replanned','action_started','action_completed','inspection_completed','inspect_completed',
22
+ 'progress_judged','critic_classified','repair_started','repair_completed','waiting_entered','waiting_resumed',
23
+ 'native_diff_committed','step_completed','phase_changed'
24
+ ]);
25
+
26
+ function sha256Object(value) {
27
+ return createHash('sha256').update(Buffer.from(canonicalJson(value),'utf8')).digest('hex');
28
+ }
29
+ function hash(value,label) {
30
+ if (typeof value !== 'string' || !HEX64.test(value)) throw new Error(`${label} invalid`);
31
+ return value;
32
+ }
33
+ function requireObject(value,label) {
34
+ if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error(`${label} invalid`);
35
+ return value;
36
+ }
37
+ function requireText(value,label,max=1024) {
38
+ if (typeof value !== 'string' || value.length < 1 || value.length > max) throw new Error(`${label} invalid`);
39
+ return value;
40
+ }
41
+ function normalizePhase(value,label) {
42
+ const normalized = LEGACY_PHASES.get(value) ?? value;
43
+ if (!PHASES.has(normalized)) throw new Error(`${label} invalid`);
44
+ return normalized;
45
+ }
46
+ function isLegacyPhase(value) { return LEGACY_PHASES.has(value) && !PHASES.has(value); }
47
+ function terminal(phase) { return phase === 'SUCCEEDED' || phase === 'FAILED'; }
48
+
49
+ function normalizedPlanForRepair(plan) {
50
+ if (!plan) return null;
51
+ return {
52
+ schema:plan.schema ?? null,
53
+ title:plan.title ?? null,
54
+ steps:Array.isArray(plan.steps) ? plan.steps.map(step => ({
55
+ step_id:step.step_id,
56
+ intent:step.intent,
57
+ status:step.status,
58
+ ...(Array.isArray(step.evidence) ? {evidence:step.evidence} : {})
59
+ })) : []
60
+ };
61
+ }
62
+
63
+ export function repairFingerprint({plan,hypothesis}) {
64
+ requireText(hypothesis,'repair hypothesis',2048);
65
+ return sha256Object({
66
+ schema:'deadbyte.autonomous-repair-fingerprint.v1',
67
+ hypothesis,
68
+ plan:normalizedPlanForRepair(plan)
69
+ });
70
+ }
71
+
72
+ function setPlan(state,plan,{replanned=false}={}) {
73
+ requireObject(plan,'loop plan');
74
+ const current = activePlanStep(plan);
75
+ state.plan = structuredClone(plan);
76
+ state.plan_id = hash(plan.plan_id,'loop plan_id');
77
+ if (!Number.isInteger(plan.plan_version) || plan.plan_version < 1) throw new Error('loop plan_version invalid');
78
+ state.plan_version = plan.plan_version;
79
+ state.current_step = current ? structuredClone(current) : null;
80
+ if (replanned) state.replan_count += 1;
81
+ }
82
+
83
+ function setPhase(state,rawFrom,rawTo) {
84
+ const from=normalizePhase(rawFrom,'loop phase from');
85
+ const to=normalizePhase(rawTo,'loop phase to');
86
+ if (state.phase !== from) throw new Error(`loop phase mismatch: journal says ${from} but derived phase is ${state.phase}`);
87
+ if (terminal(state.phase) && to !== state.phase) throw new Error(`loop ${state.phase} phase is terminal`);
88
+ const legacyTransition=isLegacyPhase(rawFrom)||isLegacyPhase(rawTo);
89
+ if (!legacyTransition && from === 'REPAIR' && ['ACT','INSPECT'].includes(to)) {
90
+ if (!state.repair?.completed || state.repair.previous_fingerprint === state.repair.repair_fingerprint) {
91
+ throw new Error('loop REPAIR requires repair fingerprint change before another ACT/INSPECT');
92
+ }
93
+ }
94
+ state.phase=to;
95
+ if (to !== 'WAITING') {
96
+ state.wait_reason=null;
97
+ state.pending_approval=false;
98
+ }
99
+ }
100
+
101
+ function classifyCritic(payload) {
102
+ const failureClass=requireText(payload.failure_class,'loop critic failure_class',64);
103
+ if (!FAILURE_CLASSES.has(failureClass)) throw new Error('loop critic failure_class invalid');
104
+ return {
105
+ failure_class:failureClass,
106
+ evidence_fingerprint:hash(payload.evidence_fingerprint,'loop critic evidence_fingerprint'),
107
+ detail:requireText(payload.detail,'loop critic detail',1024)
108
+ };
109
+ }
110
+
111
+ function repairStart(state,payload) {
112
+ if (state.phase !== 'REPAIR') throw new Error(`loop repair_started requires REPAIR phase, got ${state.phase}`);
113
+ const hypothesis=requireText(payload.hypothesis,'loop repair hypothesis',2048);
114
+ const previous=hash(payload.previous_fingerprint,'loop repair previous_fingerprint');
115
+ const expected=repairFingerprint({plan:state.plan,hypothesis});
116
+ if (previous !== expected) throw new Error('loop repair previous fingerprint mismatch');
117
+ state.repair={previous_fingerprint:previous,repair_fingerprint:null,hypothesis,completed:false};
118
+ }
119
+
120
+ function repairComplete(state,payload) {
121
+ if (state.phase !== 'REPAIR') throw new Error(`loop repair_completed requires REPAIR phase, got ${state.phase}`);
122
+ if (!state.repair) throw new Error('loop repair_completed requires repair_started');
123
+ const previous=hash(payload.previous_fingerprint,'loop repair completed previous_fingerprint');
124
+ const next=hash(payload.repair_fingerprint,'loop repair completed repair_fingerprint');
125
+ const hypothesis=requireText(payload.hypothesis,'loop repair completed hypothesis',2048);
126
+ if (previous !== state.repair.previous_fingerprint) throw new Error('loop repair previous fingerprint changed');
127
+ const expected=repairFingerprint({plan:state.plan,hypothesis});
128
+ if (next !== expected) throw new Error('loop repair fingerprint does not bind current plan/hypothesis');
129
+ if (next === previous) throw new Error('loop repair fingerprint must change before another ACT');
130
+ state.repair={previous_fingerprint:previous,repair_fingerprint:next,hypothesis,completed:true};
131
+ }
132
+
133
+ export function deriveLoopState(goal,events) {
134
+ requireObject(goal,'loop goal');
135
+ const goalId=hash(goal.goal_id,'loop goal_id');
136
+ if (!Array.isArray(events)) throw new Error('loop events must be an array');
137
+ const state={
138
+ schema:AUTONOMOUS_LOOP_STATE_SCHEMA,
139
+ phase:'PLAN',
140
+ plan:null,
141
+ plan_id:null,
142
+ plan_version:null,
143
+ current_step:null,
144
+ mutation_epoch:0,
145
+ planner_round:0,
146
+ replan_count:0,
147
+ pending_action:null,
148
+ pending_approval:false,
149
+ progress:null,
150
+ critic:null,
151
+ repair:null,
152
+ wait_reason:null,
153
+ evidence_head_sha256:null,
154
+ journal_head_sha256:ZERO_HASH
155
+ };
156
+
157
+ for (let index=0; index<events.length; index+=1) {
158
+ const event=requireObject(events[index],`loop event ${index+1}`);
159
+ if (event.goal_id !== goalId) throw new Error(`loop event ${index+1} goal mismatch`);
160
+ if (event.seq !== index+1) throw new Error(`loop event sequence mismatch at ${index+1}`);
161
+ hash(event.event_sha256,`loop event ${index+1} hash`);
162
+ const payload=event.payload===undefined?{}:requireObject(event.payload,`loop event ${index+1} payload`);
163
+
164
+ if (terminal(state.phase) && event.type !== 'release_completed' && event.type !== 'goal_cancelled') {
165
+ if (event.type === 'phase_changed') {
166
+ const to=normalizePhase(payload.to,'loop terminal phase to');
167
+ if (to !== state.phase) throw new Error(`loop ${state.phase} phase is terminal`);
168
+ } else if (MUTABLE_TERMINAL_EVENTS.has(event.type)) {
169
+ throw new Error(`loop ${state.phase} phase is terminal; event '${event.type}' is mutable`);
170
+ }
171
+ }
172
+
173
+ switch (event.type) {
174
+ case 'plan_created':
175
+ setPlan(state,payload.plan);
176
+ break;
177
+ case 'plan_replanned':
178
+ setPlan(state,payload.plan,{replanned:true});
179
+ break;
180
+ case 'step_completed':
181
+ if (payload.plan) setPlan(state,payload.plan);
182
+ break;
183
+ case 'phase_changed':
184
+ setPhase(state,payload.from,payload.to);
185
+ break;
186
+ case 'inspection_completed':
187
+ case 'inspect_completed':
188
+ if (payload.evidence_head_sha256 !== undefined) {
189
+ state.evidence_head_sha256=hash(payload.evidence_head_sha256,'loop evidence head');
190
+ }
191
+ break;
192
+ case 'action_started': {
193
+ const actionId=hash(payload.action_id,'loop action_id');
194
+ const requestSha=hash(payload.request_sha256,'loop action request_sha256');
195
+ if (state.pending_action) throw new Error('loop action_started while another action is pending');
196
+ state.pending_action={...structuredClone(payload),action_id:actionId,request_sha256:requestSha};
197
+ break;
198
+ }
199
+ case 'action_completed':
200
+ if (state.pending_action && payload.action_id !== state.pending_action.action_id) {
201
+ throw new Error('loop action completion identity mismatch');
202
+ }
203
+ if (payload.action_id !== undefined) hash(payload.action_id,'loop completed action_id');
204
+ state.pending_action=null;
205
+ break;
206
+ case 'action_reconciled':
207
+ if (payload.action_id !== undefined) hash(payload.action_id,'loop reconciled action_id');
208
+ break;
209
+ case 'progress_judged':
210
+ if (!['progress','stalled','regressed'].includes(payload.verdict)) throw new Error('loop progress verdict invalid');
211
+ state.progress=structuredClone(payload);
212
+ break;
213
+ case 'critic_classified':
214
+ state.critic=classifyCritic(payload);
215
+ break;
216
+ case 'repair_started':
217
+ repairStart(state,payload);
218
+ break;
219
+ case 'repair_completed':
220
+ repairComplete(state,payload);
221
+ break;
222
+ case 'waiting_entered':
223
+ state.phase='WAITING';
224
+ state.wait_reason=requireText(payload.reason,'loop wait reason');
225
+ state.pending_approval=payload.requires_approval===true;
226
+ break;
227
+ case 'waiting_resumed': {
228
+ if (state.phase !== 'WAITING') throw new Error('loop waiting_resumed outside WAITING phase');
229
+ const resumed=payload.to===undefined?'PLAN':normalizePhase(payload.to,'loop resume phase');
230
+ if (resumed === 'WAITING' || terminal(resumed)) throw new Error('loop waiting resume target invalid');
231
+ state.phase=resumed;
232
+ state.wait_reason=null;
233
+ state.pending_approval=false;
234
+ break;
235
+ }
236
+ case 'planner_requested':
237
+ case 'planner_decision':
238
+ if (Number.isInteger(payload.planner_round) && payload.planner_round >= 0) {
239
+ state.planner_round=Math.max(state.planner_round,payload.planner_round);
240
+ }
241
+ break;
242
+ case 'native_diff_committed':
243
+ if (!Number.isInteger(payload.mutation_epoch) || payload.mutation_epoch < state.mutation_epoch) {
244
+ throw new Error('loop mutation_epoch invalid');
245
+ }
246
+ state.mutation_epoch=payload.mutation_epoch;
247
+ break;
248
+ case 'goal_paused':
249
+ state.phase='WAITING';
250
+ state.wait_reason=typeof payload.reason==='string'&&payload.reason.length>0?payload.reason:'paused';
251
+ state.pending_approval=true;
252
+ break;
253
+ case 'goal_resumed':
254
+ if (state.phase === 'WAITING') {
255
+ state.phase='PLAN';
256
+ state.wait_reason=null;
257
+ state.pending_approval=false;
258
+ }
259
+ break;
260
+ case 'goal_cancelled':
261
+ state.phase='FAILED';
262
+ state.wait_reason=typeof payload.reason==='string'&&payload.reason.length>0?payload.reason:'cancelled';
263
+ state.pending_approval=false;
264
+ state.pending_action=null;
265
+ break;
266
+ case 'goal_failed':
267
+ state.phase='FAILED';
268
+ state.wait_reason=typeof payload.reason==='string'&&payload.reason.length>0?payload.reason:'failed';
269
+ state.pending_approval=false;
270
+ state.pending_action=null;
271
+ break;
272
+ case 'release_completed':
273
+ state.phase='SUCCEEDED';
274
+ state.wait_reason=null;
275
+ state.pending_approval=false;
276
+ state.pending_action=null;
277
+ break;
278
+ default:
279
+ break;
280
+ }
281
+ state.journal_head_sha256=event.event_sha256;
282
+ }
283
+
284
+ if (state.plan) state.current_step=activePlanStep(state.plan);
285
+ return state;
286
+ }
287
+
288
+ export function deriveTodoProjection(goal,events) {
289
+ const state=deriveLoopState(goal,events);
290
+ return Object.freeze({
291
+ schema:'deadbyte.autonomous-todo-projection.v1',
292
+ goal_id:goal.goal_id,
293
+ phase:state.phase,
294
+ plan_id:state.plan_id,
295
+ plan_version:state.plan_version,
296
+ journal_head_sha256:state.journal_head_sha256,
297
+ items:Object.freeze((state.plan?.steps ?? []).map(step => Object.freeze({
298
+ step_id:step.step_id,
299
+ intent:step.intent,
300
+ status:step.status,
301
+ ...(Array.isArray(step.evidence) ? {evidence:structuredClone(step.evidence)} : {})
302
+ })))
303
+ });
304
+ }
@@ -18,7 +18,11 @@ const replaceOperation = z.strictObject({ kind:z.literal('replace'), path:relPat
18
18
  expected_sha256:hex64, old_string:z.string().min(1).max(262144), new_string:z.string().max(524288),
19
19
  expected_replacements:z.number().int().min(1).max(64).default(1) });
20
20
  const deleteOperation = z.strictObject({ kind:z.literal('delete'), path:relPath, expected_sha256:hex64 });
21
- const nativeOperation = z.union([writeOperation,replaceOperation,deleteOperation]);
21
+ const mkdirOperation = z.strictObject({ kind:z.literal('mkdir'), path:relPath });
22
+ const moveOperation = z.strictObject({ kind:z.literal('move'), source_path:relPath, destination_path:relPath,
23
+ expected_source_identity:hex64, expected_destination_identity:z.union([z.literal('absent'),hex64]).default('absent') });
24
+ const rmdirOperation = z.strictObject({ kind:z.literal('rmdir'), path:relPath, expected_source_identity:hex64 });
25
+ const nativeOperation = z.union([writeOperation,replaceOperation,deleteOperation,mkdirOperation,moveOperation,rmdirOperation]);
22
26
  const plannerResponse = z.strictObject({ request_id:hex64, raw_text:z.string().min(2).max(8*1024*1024),
23
27
  model:z.string().min(1).max(128).default('client-model') });
24
28
  function result(schema,value,isError=false) { return autonomousStructuredResult(schema,value,isError); }
@@ -4,6 +4,24 @@ const hex64 = z.string().regex(/^[0-9a-f]{64}$/);
4
4
  const goalId = hex64;
5
5
  const jsonObject = z.record(z.string(),z.json());
6
6
  const goalState = z.enum(['pending','running','paused','cancelled','succeeded']);
7
+ const loopPhase = z.enum(['PLANNING','INSPECTING','ACTING','VERIFYING','REPLANNING','WAITING','COMPLETE']);
8
+ const loopStep = z.strictObject({
9
+ step_id:z.string().regex(/^[A-Za-z0-9._-]{1,64}$/), intent:z.string().min(1).max(512), status:z.literal('active')
10
+ });
11
+ const loopProgress = z.strictObject({
12
+ verdict:z.enum(['progress','stalled','regressed']), score:z.number(),
13
+ reason_codes:z.array(z.string().regex(/^[A-Za-z0-9._-]{1,64}$/)).max(32), fingerprint:hex64
14
+ });
15
+ const loopPendingAction = z.strictObject({
16
+ action_id:hex64, request_sha256:hex64, kind:z.string().regex(/^[A-Za-z0-9._-]{1,64}$/)
17
+ });
18
+ const publicLoopSchema = z.strictObject({
19
+ schema:z.literal('deadbyte.autonomous-loop-state.v1'), phase:loopPhase,
20
+ plan_id:hex64.nullable(), plan_version:z.number().int().min(1).nullable(),
21
+ current_step:loopStep.nullable(), replan_count:z.number().int().min(0),
22
+ progress:loopProgress.nullable(), pending_action:loopPendingAction.nullable(),
23
+ pending_approval:z.boolean(), wait_reason:z.string().min(1).max(1024).nullable()
24
+ });
7
25
  function requireFields(value,ctx,fields) {
8
26
  for (const field of fields) if (value[field] === undefined) ctx.addIssue({ code:'custom', path:[field], message:`${field} is required` });
9
27
  }
@@ -40,21 +58,21 @@ export const autonomousSessionStatusOutputSchema = statusContract({
40
58
 
41
59
  export const nativeDiffPreviewOutputSchema = statusContract({
42
60
  statuses:['ready','failed'], success:['ready'], required:['diff_id','root_id','operation_count','payload_bytes','paths','operations'],
43
- shape:{ diff_id:hex64.optional(), root_id:z.string().min(1).max(64).optional(), operation_count:z.number().int().min(1).max(32).optional(),
44
- payload_bytes:z.number().int().min(0).optional(), paths:z.array(z.string()).max(32).optional(),
61
+ shape:{ schema:z.enum(['deadbyte.native-diff.v1','deadbyte.native-diff.v2']).optional(), diff_id:hex64.optional(), root_id:z.string().min(1).max(64).optional(), operation_count:z.number().int().min(1).max(32).optional(),
62
+ payload_bytes:z.number().int().min(0).optional(), paths:z.array(z.string()).max(64).optional(),
45
63
  operations:z.array(jsonObject).max(32).optional() }
46
64
  });
47
65
  export const nativeDiffApplyOutputSchema = statusContract({
48
66
  statuses:['committed','existing','failed'], success:['committed','existing'],
49
67
  required:['diff_id','receipt_sha256','operation_count'],
50
68
  shape:{ diff_id:hex64.optional(), receipt_sha256:hex64.optional(), operation_count:z.number().int().min(1).max(32).optional(),
51
- current_state_matches:z.boolean().optional(), coding_receipts:z.array(jsonObject).max(32).optional() }
69
+ current_state_matches:z.boolean().optional(), coding_receipts:z.array(jsonObject).max(32).optional(), operation_receipts:z.array(jsonObject).max(32).optional() }
52
70
  });
53
71
  export const nativeDiffVerifyOutputSchema = z.strictObject({
54
72
  status:z.literal('failed').optional(), error:z.string().optional(), ok:z.boolean().optional(), reason:z.string().optional(),
55
73
  diff_id:hex64.optional(), receipt_sha256:hex64.optional(), signature_valid:z.literal(true).optional(),
56
74
  root_id:z.string().min(1).max(64).optional(), operation_count:z.number().int().min(1).max(32).optional(),
57
- coding_receipts_verified:z.number().int().min(0).max(32).optional(), final_states:z.array(jsonObject).max(32).optional(),
75
+ coding_receipts_verified:z.number().int().min(0).max(32).optional(), operation_receipts_verified:z.number().int().min(0).max(32).optional(), final_states:z.array(jsonObject).max(32).optional(),
58
76
  current_state_matches:z.boolean().optional(), journal_head_sha256:hex64.optional()
59
77
  }).superRefine((value,ctx) => {
60
78
  if (value.status === 'failed') { requireFields(value,ctx,['error']); return; }
@@ -72,7 +90,8 @@ export const autonomousGoalSubmitOutputSchema = statusContract({
72
90
  const runShape = Object.fromEntries(Object.entries(derivedShape).map(([key,schema]) => [key,schema.optional()]));
73
91
  export const autonomousGoalRunOutputSchema = z.strictObject({
74
92
  status:z.enum(['terminal','paused','cancelled','completed','yielded','running','input_required','failed']), error:z.string().optional(),
75
- goal_id:goalId.optional(), release:jsonObject.optional(), planner_request:jsonObject.optional(), ...runShape
93
+ goal_id:goalId.optional(), release:jsonObject.optional(), planner_request:jsonObject.optional(), loop:publicLoopSchema.optional(),
94
+ cycles:z.number().int().min(1).max(32).optional(), ...runShape
76
95
  }).superRefine((value,ctx) => {
77
96
  if (value.error !== undefined) { if (value.status !== 'failed') ctx.addIssue({code:'custom',path:['error'],message:'error wrapper requires failed'}); return; }
78
97
  requireFields(value,ctx,['goal_id',...Object.keys(derivedShape)]);
@@ -81,7 +100,7 @@ export const autonomousGoalRunOutputSchema = z.strictObject({
81
100
  export const autonomousGoalStatusOutputSchema = statusContract({
82
101
  statuses:['ok','failed'], success:['ok'], required:['goal_id','goal_sha256','title','root_id','journal_verified',...Object.keys(derivedShape)],
83
102
  shape:{ goal_id:goalId.optional(), goal_sha256:hex64.optional(), title:z.string().optional(), root_id:z.string().optional(),
84
- journal_verified:z.literal(true).optional(), ...runShape }
103
+ journal_verified:z.literal(true).optional(), loop:publicLoopSchema.optional(), ...runShape }
85
104
  });
86
105
  export const autonomousGoalEventsOutputSchema = statusContract({
87
106
  statuses:['ok','failed'], success:['ok'], required:['goal_id','journal_verified','journal_head_sha256','events'],
@@ -94,7 +113,7 @@ export const autonomousGoalCancelOutputSchema = statusContract({
94
113
  });
95
114
  export const autonomousGoalApproveOutputSchema = statusContract({
96
115
  statuses:['terminal','approved','rejected','failed'], success:['terminal','approved','rejected'], required:['goal_id','state'],
97
- shape:{ goal_id:goalId.optional(), state:goalState.optional() }
116
+ shape:{ goal_id:goalId.optional(), state:goalState.optional(), loop:publicLoopSchema.optional() }
98
117
  });
99
118
  export const autonomousReleaseGateOutputSchema = statusContract({
100
119
  statuses:['blocked','paused','failed','passed','existing','error'], success:['blocked','paused','failed','passed','existing'],
@@ -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,82 @@ 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 plannerCursor=z.string().max(4096).nullable().default(null);
93
+ const plannerFiles=z.array(z.strictObject({path:relPath,encoding:z.enum(['utf8','base64']).default('utf8')})).min(1).max(32);
94
+ const plannerSemanticPosition={path:relPath,line:z.number().int().min(0),column:z.number().int().min(0)};
95
+ const r36TypedActionSchemas=[
96
+ z.strictObject({kind:z.literal('search'),path:relPath.default('.'),target:z.enum(['content','path']).default('content'),mode:z.enum(['literal','regex']).default('literal'),pattern:z.string().min(1).max(256),case_sensitive:z.boolean().default(false),max_results:z.number().int().min(1).max(1000).default(200),max_file_bytes:z.number().int().min(1).max(4194304).default(262144),max_scan_bytes:z.number().int().min(1).max(67108864).default(4194304),page_size:z.number().int().min(1).max(500).default(100),cursor:plannerCursor}),
97
+ z.strictObject({kind:z.literal('stat'),path:relPath.default('.'),hash:z.boolean().default(false)}),
98
+ z.strictObject({kind:z.literal('multi_read'),files:plannerFiles,max_total_bytes:z.number().int().min(1).max(2097152).default(1048576)}),
99
+ z.strictObject({kind:z.literal('semantic_outline'),path:relPath,max_symbols:z.number().int().min(1).max(500).default(200)}),
100
+ z.strictObject({kind:z.literal('semantic_definition'),...plannerSemanticPosition,max_results:z.number().int().min(1).max(200).default(50)}),
101
+ z.strictObject({kind:z.literal('semantic_references'),...plannerSemanticPosition,max_results:z.number().int().min(1).max(500).default(200)}),
102
+ z.strictObject({kind:z.literal('semantic_diagnostics'),path:relPath,max_results:z.number().int().min(1).max(500).default(200)}),
103
+ z.strictObject({kind:z.literal('semantic_implementations'),...plannerSemanticPosition,max_results:z.number().int().min(1).max(500).default(200)}),
104
+ z.strictObject({kind:z.literal('semantic_rename_preview'),...plannerSemanticPosition,new_name:z.string().regex(/^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/)}),
105
+ z.strictObject({kind:z.literal('native_diff_apply'),diff_id:z.string().regex(HEX64),expected_operation_count:z.number().int().min(1).max(32)}),
106
+ z.strictObject({kind:z.literal('native_diff_verify'),diff_id:z.string().regex(HEX64)}),
107
+ z.strictObject({kind:z.literal('process_start'),profile_id:z.string().regex(ID),cwd:relPath.default('.'),args:z.array(z.string().max(2048)).max(64).default([])}),
108
+ z.strictObject({kind:z.literal('process_read'),session_id:z.string().regex(HEX64),offset:z.number().int().min(0).default(0),max_bytes:z.number().int().min(1).max(262144).default(65536)}),
109
+ z.strictObject({kind:z.literal('process_status'),session_id:z.string().regex(HEX64)}),
110
+ z.strictObject({kind:z.literal('process_list')}),
111
+ z.strictObject({kind:z.literal('process_action'),session_id:z.string().regex(HEX64),action_id:z.string().regex(ID)}),
112
+ z.strictObject({kind:z.literal('process_terminate'),session_id:z.string().regex(HEX64)}),
113
+ z.strictObject({kind:z.literal('machine_fs_stat'),path:relPath.default('.'),hash:z.boolean().default(false)}),
114
+ z.strictObject({kind:z.literal('machine_fs_list'),path:relPath.default('.'),cursor:plannerCursor,limit:z.number().int().min(1).max(1000).default(100),hash_files:z.boolean().default(false)}),
115
+ z.strictObject({kind:z.literal('machine_fs_read'),path:relPath,offset:z.number().int().min(0).default(0),max_bytes:z.number().int().min(1).max(4194304).default(65536),hash_file:z.boolean().default(false)}),
116
+ z.strictObject({kind:z.literal('machine_fs_mkdir'),path:relPath}),
117
+ z.strictObject({kind:z.literal('machine_fs_move'),source_path:relPath,destination_path:relPath,expected_source_identity:z.string().regex(HEX64)}),
118
+ z.strictObject({kind:z.literal('machine_fs_delete'),path:relPath,expected_source_identity:z.string().regex(HEX64)}),
119
+ z.strictObject({kind:z.literal('observation_search_start'),path:relPath.default('.'),pattern:z.string().min(1).max(256),case_sensitive:z.boolean().default(false),max_results:z.number().int().min(1).max(1000).default(200),max_files:z.number().int().min(1).max(10000).default(2000),max_bytes:z.number().int().min(1).max(67108864).default(4194304),max_file_bytes:z.number().int().min(1).max(4194304).default(262144)}),
120
+ z.strictObject({kind:z.literal('observation_search_status'),search_id:z.string().regex(HEX64)}),
121
+ z.strictObject({kind:z.literal('observation_search_page'),search_id:z.string().regex(HEX64),cursor:plannerCursor,limit:z.number().int().min(1).max(500).default(100)}),
122
+ z.strictObject({kind:z.literal('observation_search_cancel'),search_id:z.string().regex(HEX64)}),
123
+ z.strictObject({kind:z.literal('observation_process_list'),include_external:z.boolean().default(false),cursor:plannerCursor,limit:z.number().int().min(1).max(256).default(100)}),
124
+ z.strictObject({kind:z.literal('observation_system_status')})
125
+ ];
126
+ const r34ActionSchema = z.discriminatedUnion('kind',[
127
+ z.strictObject({kind:z.literal('patch'),operations:z.array(r34PatchOperationSchema).min(1).max(32)}),
128
+ z.strictObject({kind:z.literal('run_profile'),profile_id:z.string().regex(ID)}),
129
+ z.strictObject({kind:z.literal('delegate'),operation:z.record(z.string(),z.json())}),
130
+ ...r36TypedActionSchemas
131
+ ]);
132
+ const r34ReadSchema = z.strictObject({
133
+ path:relPath,
134
+ max_bytes:z.number().int().min(1).max(262144).default(65536)
135
+ });
136
+
137
+ export const r34PlannerDecisionSchema = z.discriminatedUnion('kind',[
138
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('plan_create'),
139
+ title:z.string().min(1).max(160),reason:z.string().min(1).max(512).optional(),
140
+ steps:z.array(r34PlanStepSchema).min(1).max(24)}),
141
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('inspect'),
142
+ reads:z.array(r34ReadSchema).min(1).max(8)}),
143
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('act'),action:r34ActionSchema}),
144
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('step_complete'),
145
+ step_id:z.string().regex(ID),evidence:z.array(r34EvidenceSchema).min(1).max(32)}),
146
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('replan'),
147
+ reason:z.string().min(1).max(512),steps:z.array(r34PlanStepSchema).min(1).max(24)}),
148
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('pause'),
149
+ reason:z.string().min(1).max(1000)}),
150
+ z.strictObject({schema:z.literal('deadbyte.autonomous-decision.v2'),kind:z.literal('finish'),
151
+ summary:z.string().min(1).max(1024).optional()})
152
+ ]);