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,142 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { canonicalJson } from './canonical-json.mjs';
3
+
4
+ const HEX64 = /^[0-9a-f]{64}$/;
5
+ const ID = /^[A-Za-z0-9._-]{1,64}$/;
6
+ const RECEIPT_ID = /^[0-9a-f]{24}$/;
7
+
8
+ function sha256Object(value) {
9
+ return createHash('sha256').update(Buffer.from(canonicalJson(value),'utf8')).digest('hex');
10
+ }
11
+
12
+ function hash(value,label) {
13
+ if (typeof value !== 'string' || !HEX64.test(value)) throw new Error(`${label} invalid`);
14
+ return value;
15
+ }
16
+
17
+ function id(value,label) {
18
+ if (typeof value !== 'string' || !ID.test(value)) throw new Error(`${label} invalid`);
19
+ return value;
20
+ }
21
+
22
+ function integer(value,label) {
23
+ if (!Number.isInteger(value) || value < 0) throw new Error(`${label} invalid`);
24
+ return value;
25
+ }
26
+
27
+ function classification(classification,evidence = null,reason = null) {
28
+ return Object.freeze({
29
+ classification,
30
+ replay_allowed:classification === 'not_executed',
31
+ evidence:evidence === null ? null : Object.freeze({...evidence}),
32
+ reason
33
+ });
34
+ }
35
+
36
+ export function actionIdentity({ goalId, planId, planVersion, stepId, mutationEpoch, decisionEventSha, action }) {
37
+ hash(goalId,'action goalId');
38
+ hash(planId,'action planId');
39
+ if (!Number.isInteger(planVersion) || planVersion < 1) throw new Error('action planVersion invalid');
40
+ id(stepId,'action stepId');
41
+ integer(mutationEpoch,'action mutationEpoch');
42
+ hash(decisionEventSha,'action decisionEventSha');
43
+ if (!action || typeof action !== 'object' || Array.isArray(action)) throw new Error('action payload invalid');
44
+ const request = {
45
+ schema:'deadbyte.autonomous-action-request.v1',
46
+ goal_id:goalId,
47
+ plan_id:planId,
48
+ plan_version:planVersion,
49
+ step_id:stepId,
50
+ mutation_epoch:mutationEpoch,
51
+ decision_event_sha256:decisionEventSha,
52
+ action:structuredClone(action)
53
+ };
54
+ const requestSha256 = sha256Object(request);
55
+ const actionId = sha256Object({schema:'deadbyte.autonomous-action-id.v1',request_sha256:requestSha256});
56
+ return Object.freeze({ action_id:actionId, request_sha256:requestSha256 });
57
+ }
58
+
59
+ function missingEvidence(reason) {
60
+ return typeof reason === 'string' && /(?:missing|not found|unavailable|enoent|absent)/i.test(reason);
61
+ }
62
+
63
+ function validateStarted(startedEvent) {
64
+ if (!startedEvent || typeof startedEvent !== 'object' || startedEvent.type !== 'action_started') {
65
+ throw new Error('reconcile requires action_started event');
66
+ }
67
+ const payload = startedEvent.payload;
68
+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)) throw new Error('action_started payload invalid');
69
+ hash(payload.action_id,'started action_id');
70
+ hash(payload.request_sha256,'started request_sha256');
71
+ if (!payload.action || typeof payload.action !== 'object' || Array.isArray(payload.action)) throw new Error('started action payload missing');
72
+ return payload;
73
+ }
74
+
75
+ async function reconcilePatch(payload,runtimes) {
76
+ const diffId = hash(payload.action.diff_id,'started patch diff_id');
77
+ if (!runtimes?.nativeDiffRuntime?.verify) return classification('ambiguous',null,'native diff verifier unavailable');
78
+ let checked;
79
+ try { checked = await runtimes.nativeDiffRuntime.verify({diffId}); }
80
+ catch (error) {
81
+ const reason = String(error?.message ?? error);
82
+ return missingEvidence(reason) ? classification('not_executed',null,reason) : classification('ambiguous',null,reason);
83
+ }
84
+ if (checked?.ok === true) {
85
+ if (checked.current_state_matches !== true) return classification('ambiguous',null,'native diff current state mismatch');
86
+ if (!HEX64.test(checked.receipt_sha256 ?? '')) return classification('ambiguous',null,'native diff verified without receipt hash');
87
+ return classification('executed_verified',{
88
+ kind:'native_diff',
89
+ diff_id:diffId,
90
+ receipt_sha256:checked.receipt_sha256,
91
+ ...(HEX64.test(checked.journal_head_sha256 ?? '') ? {journal_head_sha256:checked.journal_head_sha256} : {})
92
+ });
93
+ }
94
+ const reason = String(checked?.reason ?? 'native diff verification failed');
95
+ return missingEvidence(reason) ? classification('not_executed',null,reason) : classification('ambiguous',null,reason);
96
+ }
97
+
98
+ async function reconcileProfile(payload,runtimes) {
99
+ const receiptId = payload.action.receipt_id;
100
+ if (typeof receiptId !== 'string' || !RECEIPT_ID.test(receiptId)) return classification('ambiguous',null,'profile receipt id invalid');
101
+ if (!runtimes?.codingRuntime?.verifyReceiptDetailed) return classification('ambiguous',null,'coding receipt verifier unavailable');
102
+ let checked;
103
+ try { checked = await runtimes.codingRuntime.verifyReceiptDetailed(receiptId); }
104
+ catch (error) {
105
+ const reason = String(error?.message ?? error);
106
+ return missingEvidence(reason) ? classification('not_executed',null,reason) : classification('ambiguous',null,reason);
107
+ }
108
+ if (checked?.ok !== true) {
109
+ const reason = String(checked?.reason ?? 'coding receipt verification failed');
110
+ return missingEvidence(reason) ? classification('not_executed',null,reason) : classification('ambiguous',null,reason);
111
+ }
112
+ if (checked.request_sha256 !== payload.request_sha256) return classification('ambiguous',null,'coding receipt request identity mismatch');
113
+ if (!HEX64.test(checked.receipt_sha256 ?? '')) return classification('ambiguous',null,'coding receipt hash invalid');
114
+ const receipt = checked.receipt;
115
+ if (!receipt || receipt.receipt_id !== receiptId) return classification('ambiguous',null,'coding receipt substitution detected');
116
+ const evidence = {kind:'coding_receipt',receipt_id:receiptId,receipt_sha256:checked.receipt_sha256,request_sha256:checked.request_sha256};
117
+ if (receipt.operation === 'coding_command_run') {
118
+ const expected = Number.isInteger(payload.action.expect_exit_code) ? payload.action.expect_exit_code : 0;
119
+ const passed = receipt.timed_out !== true && receipt.exit_code === expected;
120
+ return classification(passed ? 'executed_verified' : 'executed_failed_verified',evidence,passed ? null : 'verified command outcome failed');
121
+ }
122
+ if (receipt.operation === 'coding_benchmark_run') {
123
+ const passed = receipt.verdict === 'pass';
124
+ return classification(passed ? 'executed_verified' : 'executed_failed_verified',evidence,passed ? null : 'verified benchmark outcome failed');
125
+ }
126
+ return classification('ambiguous',null,'coding receipt operation mismatch');
127
+ }
128
+
129
+ export async function reconcileStartedAction({ startedEvent, journal = [], runtimes = {} } = {}) {
130
+ const payload = validateStarted(startedEvent);
131
+ if (!Array.isArray(journal)) throw new Error('reconcile journal must be an array');
132
+ const completed = journal.find(event => event?.type === 'action_completed' && event?.payload?.action_id === payload.action_id);
133
+ if (completed) {
134
+ return classification('executed_verified',{
135
+ kind:'journal_completion',
136
+ event_sha256:HEX64.test(completed.event_sha256 ?? '') ? completed.event_sha256 : null
137
+ },'matching verified journal completion already exists');
138
+ }
139
+ if (payload.action.kind === 'patch') return reconcilePatch(payload,runtimes);
140
+ if (payload.action.kind === 'profile') return reconcileProfile(payload,runtimes);
141
+ return classification('ambiguous',null,`unsupported interrupted action kind '${String(payload.action.kind)}'`);
142
+ }
@@ -0,0 +1,256 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { canonicalJson } from './canonical-json.mjs';
3
+ import { provenanceFor, dedupeEvidence } from './context-provenance.mjs';
4
+
5
+ const SECRET_KEY = /(?:^|[_-])(token|password|secret|authorization|cookie|credential|credentials|api[_-]?key|private[_-]?key|recovery)(?:$|[_-])/i;
6
+ const HEX64 = /^[0-9a-f]{64}$/;
7
+
8
+ const sha256Text = text => createHash('sha256').update(Buffer.from(text,'utf8')).digest('hex');
9
+ const bytesOf = value => Buffer.byteLength(canonicalJson(value),'utf8');
10
+
11
+ function utf8Bytes(value) {
12
+ if (typeof value === 'string') return Buffer.byteLength(value,'utf8');
13
+ return Buffer.byteLength(canonicalJson(value),'utf8');
14
+ }
15
+
16
+ function sanitize(value,key = '') {
17
+ if (SECRET_KEY.test(key)) {
18
+ return { redacted:true, reason:'secret', byte_count:utf8Bytes(value) };
19
+ }
20
+ if (Array.isArray(value)) return value.map(item => sanitize(item,''));
21
+ if (value && typeof value === 'object') {
22
+ const out = {};
23
+ for (const name of Object.keys(value).sort()) out[name] = sanitize(value[name],name);
24
+ return out;
25
+ }
26
+ return value;
27
+ }
28
+
29
+ function elideStringField(object,field,{hash = true}={}) {
30
+ if (!object || typeof object !== 'object' || typeof object[field] !== 'string') return false;
31
+ const text = object[field];
32
+ object[`${field}_elided`] = true;
33
+ object[`${field}_bytes`] = Buffer.byteLength(text,'utf8');
34
+ if (hash) object[`${field}_sha256`] = sha256Text(text);
35
+ delete object[field];
36
+ return true;
37
+ }
38
+
39
+ function compactHistorical(state,fits) {
40
+ const events = state.historical_evidence?.compacted_events ?? [];
41
+ for (const event of events) {
42
+ for (const field of ['raw_payload','content','stdout_excerpt','stderr_excerpt','old_string','new_string','data_base64']) {
43
+ elideStringField(event,field);
44
+ }
45
+ if (fits()) return;
46
+ }
47
+ const observations = state.historical_evidence?.observations ?? [];
48
+ for (const observation of observations) {
49
+ for (const field of ['stdout_excerpt','stderr_excerpt','content','raw_payload']) elideStringField(observation,field);
50
+ if (fits()) return;
51
+ }
52
+ }
53
+
54
+ function compactWorking(state,fits) {
55
+ const contexts = state.working_context?.recent_contexts ?? [];
56
+ for (let index = 0; index < Math.max(0,contexts.length - 1) && !fits(); index += 1) {
57
+ elideStringField(contexts[index],'content');
58
+ }
59
+ const observations = state.working_context?.recent_observations ?? [];
60
+ for (let index = 0; index < Math.max(0,observations.length - 1) && !fits(); index += 1) {
61
+ elideStringField(observations[index],'stdout_excerpt');
62
+ elideStringField(observations[index],'stderr_excerpt');
63
+ elideStringField(observations[index],'content');
64
+ }
65
+ if (!fits() && Array.isArray(state.working_context?.tree) && state.working_context.tree.length > 128) {
66
+ const original = state.working_context.tree.length;
67
+ state.working_context.tree = state.working_context.tree.slice(0,128);
68
+ state.working_context.tree_compaction = { original_entries:original, kept_entries:128 };
69
+ }
70
+ }
71
+
72
+ export function compactLoopContext(input,maxBytes) {
73
+ if (!Number.isInteger(maxBytes) || maxBytes < 1024) throw new Error('loop context maxBytes invalid');
74
+ const state = sanitize(structuredClone(input));
75
+ const fits = () => bytesOf(state) <= maxBytes;
76
+ if (fits()) return state;
77
+ compactHistorical(state,fits);
78
+ if (fits()) return state;
79
+ compactWorking(state,fits);
80
+ if (fits()) return state;
81
+ throw new Error('autonomous loop context exceeds policy budget after deterministic compaction');
82
+ }
83
+
84
+ function uniqueStrings(values) {
85
+ return [...new Set(values.filter(value => typeof value === 'string' && value.length > 0))];
86
+ }
87
+
88
+ export function deriveProjectMemory(events) {
89
+ if (!Array.isArray(events)) throw new Error('project memory events must be an array');
90
+ const acceptance = [];
91
+ const proven = [];
92
+ const rejected = [];
93
+ const files = new Map();
94
+ const blockers = new Map();
95
+
96
+ for (const event of events) {
97
+ if (!event || typeof event !== 'object' || Array.isArray(event)) continue;
98
+ const payload = event.payload && typeof event.payload === 'object' && !Array.isArray(event.payload) ? event.payload : {};
99
+ if (event.type === 'goal_created' && typeof payload.acceptance === 'string' && payload.acceptance.length > 0) {
100
+ acceptance.push(payload.acceptance);
101
+ }
102
+ if (event.type === 'profile_completed' && typeof payload.profile_id === 'string') {
103
+ const key = `profile:${payload.profile_id}`;
104
+ if (payload.passed === false) blockers.set(key,`${payload.profile_id}_failed`);
105
+ if (payload.passed === true) {
106
+ blockers.delete(key);
107
+ proven.push(`${payload.profile_id}:passed`);
108
+ }
109
+ }
110
+ if (event.type === 'planner_rejected' && typeof payload.reason === 'string') rejected.push(payload.reason);
111
+ if (event.type === 'native_diff_committed') {
112
+ for (const file of payload.paths ?? []) {
113
+ if (typeof file === 'string' && file.length > 0) {
114
+ files.set(file,{ path:file, ...(HEX64.test(payload.diff_receipt_sha256 ?? '') ? { receipt_sha256:payload.diff_receipt_sha256 } : {}) });
115
+ }
116
+ }
117
+ }
118
+ if (event.type === 'waiting_entered' && typeof payload.reason === 'string') blockers.set(`wait:${payload.reason}`,payload.reason);
119
+ if (event.type === 'waiting_resumed' && typeof payload.previous_reason === 'string') blockers.delete(`wait:${payload.previous_reason}`);
120
+ }
121
+
122
+ return {
123
+ acceptance_constraints:uniqueStrings(acceptance),
124
+ proven_invariants:uniqueStrings(proven),
125
+ rejected_approaches:uniqueStrings(rejected),
126
+ important_files:[...files.values()].sort((a,b) => a.path.localeCompare(b.path,'en')),
127
+ unresolved_blockers:[...blockers.values()].sort((a,b) => a.localeCompare(b,'en'))
128
+ };
129
+ }
130
+
131
+ const LEGACY_OBSERVED_AT_UTC='1970-01-01T00:00:00.000Z';
132
+
133
+ function provenancePayload(item,kind){
134
+ if(kind==='context'&&typeof item?.content==='string') return item.content;
135
+ const payload=structuredClone(item??{});
136
+ delete payload.provenance;
137
+ delete payload.observed_at_utc;
138
+ delete payload.trust_class;
139
+ delete payload.relevance_epoch;
140
+ return payload;
141
+ }
142
+
143
+ function provenanceSourceId(item,kind,index){
144
+ const candidates=kind==='context'
145
+ ? [item?.source_id,item?.path,HEX64.test(item?.sha256??'')?`sha256:${item.sha256}`:null]
146
+ : [item?.source_id,item?.profile_id?`profile:${item.profile_id}`:null,HEX64.test(item?.request_sha256??'')?`request:${item.request_sha256}`:null,item?.session_id?`session:${item.session_id}`:null,item?.search_id?`search:${item.search_id}`:null,item?.diff_id?`diff:${item.diff_id}`:null,HEX64.test(item?.receipt_sha256??'')?`receipt:${item.receipt_sha256}`:null];
147
+ const selected=candidates.find(value=>typeof value==='string'&&value.length>0);
148
+ return selected??`${kind}:legacy:${index}`;
149
+ }
150
+
151
+ function normalizeEvidence(items,{kind,relevanceEpoch}){
152
+ if(!Array.isArray(items)) throw new Error(`${kind} evidence must be an array`);
153
+ const mapped=items.map((item,index)=>{
154
+ if(!item||typeof item!=='object'||Array.isArray(item)) throw new Error(`${kind} evidence ${index+1} invalid`);
155
+ if(item.provenance) return structuredClone(item);
156
+ const observed=typeof item.observed_at_utc==='string'&&item.observed_at_utc.length>0?item.observed_at_utc:LEGACY_OBSERVED_AT_UTC;
157
+ const stamped={...structuredClone(item)};
158
+ if(!stamped.observed_at_utc) stamped.observed_at_utc=observed;
159
+ stamped.provenance=provenanceFor({
160
+ sourceKind:kind,
161
+ sourceId:provenanceSourceId(item,kind,index),
162
+ bytes:provenancePayload(item,kind),
163
+ observedAtUtc:observed,
164
+ trustClass:typeof item.trust_class==='string'&&item.trust_class.length>0?item.trust_class:(observed===LEGACY_OBSERVED_AT_UTC?'legacy_unstamped':kind==='context'?'workspace_read':HEX64.test(item.receipt_sha256??'')?'signed_receipt':'runtime_observation'),
165
+ relevanceEpoch:Number.isInteger(item.relevance_epoch)&&item.relevance_epoch>=0?item.relevance_epoch:relevanceEpoch
166
+ });
167
+ return stamped;
168
+ });
169
+ return dedupeEvidence(mapped);
170
+ }
171
+
172
+ function activeIdentities(observations) {
173
+ const out = [];
174
+ const seen = new Set();
175
+ for (const observation of observations) {
176
+ if (!observation || typeof observation !== 'object') continue;
177
+ for (const field of ['session_id','search_id','diff_id','receipt_id']) {
178
+ const value = observation[field] ?? observation.result?.[field] ?? observation.evidence?.[field];
179
+ if (typeof value !== 'string' || value.length < 1) continue;
180
+ const key = `${field}:${value}`;
181
+ if (seen.has(key)) continue;
182
+ seen.add(key);
183
+ out.push({ kind:field.replace(/_id$/,''), id:value });
184
+ }
185
+ }
186
+ return out;
187
+ }
188
+
189
+ function historicalEvidence({ contexts, observations, loopState }) {
190
+ const oldContexts = contexts.slice(0,Math.max(0,contexts.length - 16)).map(item => ({ kind:'context', ...structuredClone(item) }));
191
+ const oldObservations = observations.slice(0,Math.max(0,observations.length - 24)).map(item => ({ kind:'observation', ...structuredClone(item) }));
192
+ const failures = observations.filter(item => item?.passed === false || item?.status === 'failed' || item?.error)
193
+ .map(item => ({
194
+ profile_id:item.profile_id ?? null,
195
+ cause:item.reason ?? item.error ?? (item.profile_id ? `${item.profile_id}_failed` : 'operation_failed'),
196
+ ...(HEX64.test(item.receipt_sha256 ?? '') ? { receipt_sha256:item.receipt_sha256 } : {})
197
+ }));
198
+ const receipts = observations.filter(item => HEX64.test(item?.receipt_sha256 ?? '')).map(item => ({
199
+ receipt_id:typeof item.receipt_id === 'string' ? item.receipt_id : null,
200
+ receipt_sha256:item.receipt_sha256,
201
+ ...(HEX64.test(item.request_sha256 ?? '') ? { request_sha256:item.request_sha256 } : {})
202
+ }));
203
+ const mutationEpochs = uniqueStrings(observations.map(item => Number.isInteger(item?.mutation_epoch) ? String(item.mutation_epoch) : ''))
204
+ .map(Number);
205
+ if (Number.isInteger(loopState?.mutation_epoch) && !mutationEpochs.includes(loopState.mutation_epoch)) mutationEpochs.push(loopState.mutation_epoch);
206
+ mutationEpochs.sort((a,b) => a-b);
207
+ return {
208
+ compacted_events:[...oldContexts,...oldObservations],
209
+ failures,
210
+ receipts,
211
+ mutation_epochs:mutationEpochs,
212
+ plan_transitions:[]
213
+ };
214
+ }
215
+
216
+ export function buildLoopContext({ goal, policy, loopState = {}, tree = [], contexts = [], observations = [], decisions = [], projectMemory = null, capabilities = null }) {
217
+ if (!policy?.limits || !Number.isInteger(policy.limits.max_context_bytes)) throw new Error('loop context policy byte limit missing');
218
+ const relevanceEpoch=Number.isInteger(loopState?.mutation_epoch)&&loopState.mutation_epoch>=0?loopState.mutation_epoch:0;
219
+ const retainedContexts=normalizeEvidence(contexts,{kind:'context',relevanceEpoch});
220
+ const retainedObservations=normalizeEvidence(observations,{kind:'observation',relevanceEpoch});
221
+ const profiles = Object.entries(policy.profiles ?? {}).map(([id,profile]) => ({
222
+ id,
223
+ kind:profile.kind,
224
+ required_for_release:profile.required_for_release === true,
225
+ description:profile.description ?? ''
226
+ }));
227
+ const memory = projectMemory === null ? {
228
+ acceptance_constraints:typeof goal?.acceptance === 'string' && goal.acceptance.length > 0 ? [goal.acceptance] : [],
229
+ proven_invariants:[],rejected_approaches:[],important_files:[],unresolved_blockers:[]
230
+ } : structuredClone(projectMemory);
231
+ const state = {
232
+ goal:structuredClone(goal ?? {}),
233
+ loop:{
234
+ phase:loopState.phase ?? null,
235
+ mutation_epoch:Number.isInteger(loopState.mutation_epoch) ? loopState.mutation_epoch : 0,
236
+ planner_round:Number.isInteger(loopState.planner_round) ? loopState.planner_round : 0,
237
+ plan_id:loopState.plan_id ?? null,
238
+ plan_version:loopState.plan_version ?? null,
239
+ replan_count:Number.isInteger(loopState.replan_count) ? loopState.replan_count : 0
240
+ },
241
+ working_context:{
242
+ active_plan:structuredClone(loopState.plan ?? loopState.active_plan ?? null),
243
+ current_step:structuredClone(loopState.current_step ?? null),
244
+ recent_contexts:structuredClone(retainedContexts.slice(-16)),
245
+ recent_observations:structuredClone(retainedObservations.slice(-24)),
246
+ active_identities:activeIdentities(retainedObservations.slice(-24)),
247
+ recent_decisions:structuredClone(decisions.slice(-8)),
248
+ tree:structuredClone(tree)
249
+ },
250
+ historical_evidence:historicalEvidence({contexts:retainedContexts,observations:retainedObservations,loopState}),
251
+ project_memory:memory,
252
+ capabilities:capabilities===null?null:structuredClone(capabilities),
253
+ profiles
254
+ };
255
+ return compactLoopContext(state,policy.limits.max_context_bytes);
256
+ }
@@ -0,0 +1,17 @@
1
+ export function promptContexts(state) {
2
+ if (Array.isArray(state?.working_context?.recent_contexts)) return state.working_context.recent_contexts;
3
+ if (Array.isArray(state?.contexts)) return state.contexts;
4
+ return [];
5
+ }
6
+
7
+ export function promptObservations(state) {
8
+ if (Array.isArray(state?.working_context?.recent_observations)) return state.working_context.recent_observations;
9
+ if (Array.isArray(state?.observations)) return state.observations;
10
+ return [];
11
+ }
12
+
13
+ export function promptMutationEpoch(state) {
14
+ if (Number.isInteger(state?.loop?.mutation_epoch)) return state.loop.mutation_epoch;
15
+ if (Number.isInteger(state?.mutation_epoch)) return state.mutation_epoch;
16
+ return 0;
17
+ }
@@ -0,0 +1,249 @@
1
+ import { createHash, randomBytes } from 'node:crypto';
2
+ import { execFile } from 'node:child_process';
3
+ import { promisify } from 'node:util';
4
+ import { access, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
5
+ import path from 'node:path';
6
+ import { startAutonomousSupervisor } from './autonomous-supervisor.mjs';
7
+
8
+ const execFileAsync=promisify(execFile);
9
+ export const AUTONOMOUS_SUPERVISOR_OWNER_SCHEMA='deadbyte.autonomous-supervisor-owner.v1';
10
+ const HEX64=/^[0-9a-f]{64}$/;
11
+ const RECOVERY_OPERATIONS=Object.freeze(['status','resume','park','disarmautonomous','disarmcoding','disarmprocess','disarmhost']);
12
+ const RECOVERY_SET=new Set(RECOVERY_OPERATIONS);
13
+
14
+ function sha256Bytes(bytes){ return createHash('sha256').update(bytes).digest('hex'); }
15
+ function isIso(value){ return typeof value==='string' && Number.isFinite(Date.parse(value)); }
16
+ function samePath(a,b){
17
+ if(typeof a!=='string'||typeof b!=='string') return false;
18
+ return path.resolve(a).toLowerCase()===path.resolve(b).toLowerCase();
19
+ }
20
+ function assertOptions(options){
21
+ if(!options||typeof options!=='object'||Array.isArray(options)) throw new Error('supervisor options invalid');
22
+ if(typeof options.markerPath!=='string'||options.markerPath.length<3) throw new Error('supervisor markerPath invalid');
23
+ return path.resolve(options.markerPath);
24
+ }
25
+ function validateMarker(marker){
26
+ if(!marker||typeof marker!=='object'||Array.isArray(marker)) return false;
27
+ const keys=Object.keys(marker).sort();
28
+ const expected=['creation_time_utc','image_path','image_sha256','instance_nonce','pid','schema','started_at_utc'].sort();
29
+ if(JSON.stringify(keys)!==JSON.stringify(expected)) return false;
30
+ return marker.schema===AUTONOMOUS_SUPERVISOR_OWNER_SCHEMA && Number.isInteger(marker.pid) && marker.pid>0 &&
31
+ isIso(marker.creation_time_utc) && typeof marker.image_path==='string' && marker.image_path.length>3 &&
32
+ HEX64.test(marker.image_sha256??'') && HEX64.test(marker.instance_nonce??'') && isIso(marker.started_at_utc);
33
+ }
34
+ async function powershellPath(){
35
+ if(process.platform!=='win32') return null;
36
+ const systemRoot=process.env.SystemRoot || process.env.WINDIR;
37
+ if(systemRoot){
38
+ const candidate=path.join(systemRoot,'System32','WindowsPowerShell','v1.0','powershell.exe');
39
+ try { await access(candidate); return candidate; } catch {}
40
+ }
41
+ return 'powershell.exe';
42
+ }
43
+
44
+ export async function observeCurrentProcessIdentity(pid=process.pid){
45
+ if(!Number.isInteger(pid)||pid<=0) throw new Error('process pid invalid');
46
+ const shell=await powershellPath();
47
+ if(!shell) return null;
48
+ const script=`$ErrorActionPreference='Stop'; $p=Get-Process -Id ${pid} -ErrorAction Stop; $image=''; try { $image=[string]$p.Path } catch {}; if([string]::IsNullOrWhiteSpace($image)){ try { $c=Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}' -ErrorAction Stop; $image=[string]$c.ExecutablePath } catch {} }; if([string]::IsNullOrWhiteSpace($image)){ exit 3 }; [pscustomobject]@{pid=[int]$p.Id;creation_time_utc=$p.StartTime.ToUniversalTime().ToString('o');image_path=[System.IO.Path]::GetFullPath($image)} | ConvertTo-Json -Compress`;
49
+ let stdout;
50
+ try {
51
+ ({stdout}=await execFileAsync(shell,['-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-Command',script],{
52
+ windowsHide:true,timeout:10_000,maxBuffer:1024*1024,encoding:'utf8'
53
+ }));
54
+ } catch { return null; }
55
+ let parsed;
56
+ try { parsed=JSON.parse(String(stdout).trim()); } catch { return null; }
57
+ if(parsed?.pid!==pid||!isIso(parsed?.creation_time_utc)||typeof parsed?.image_path!=='string') return null;
58
+ const imagePath=path.resolve(parsed.image_path);
59
+ let imageBytes;
60
+ try { imageBytes=await readFile(imagePath); } catch { return null; }
61
+ return Object.freeze({
62
+ pid,creation_time_utc:new Date(parsed.creation_time_utc).toISOString(),
63
+ image_path:imagePath,image_sha256:sha256Bytes(imageBytes)
64
+ });
65
+ }
66
+
67
+ async function readMarker(markerPath){
68
+ let raw;
69
+ try { raw=await readFile(markerPath); }
70
+ catch(error){ if(error?.code==='ENOENT') return {exists:false}; throw error; }
71
+ let marker;
72
+ try { marker=JSON.parse(raw.toString('utf8')); }
73
+ catch { return {exists:true,raw,raw_sha256:sha256Bytes(raw),valid:false,marker:null}; }
74
+ return {exists:true,raw,raw_sha256:sha256Bytes(raw),valid:validateMarker(marker),marker};
75
+ }
76
+ function markerFor(identity){
77
+ return {
78
+ schema:AUTONOMOUS_SUPERVISOR_OWNER_SCHEMA,
79
+ pid:identity.pid,creation_time_utc:identity.creation_time_utc,image_path:identity.image_path,
80
+ image_sha256:identity.image_sha256,instance_nonce:randomBytes(32).toString('hex'),
81
+ started_at_utc:new Date().toISOString()
82
+ };
83
+ }
84
+ async function currentMarker(){
85
+ const identity=await observeCurrentProcessIdentity();
86
+ if(!identity) throw new Error('supervisor current Windows process identity unavailable');
87
+ return markerFor(identity);
88
+ }
89
+
90
+ export async function observeSupervisor(options={}){
91
+ const markerPath=assertOptions(options);
92
+ const stored=await readMarker(markerPath);
93
+ if(!stored.exists) return {status:'absent',live:false,reason:'no_owner',marker:null,marker_sha256:null};
94
+ if(!stored.valid) return {status:'unverified',live:false,reason:'marker_invalid',marker:stored.marker,marker_sha256:stored.raw_sha256};
95
+ const observed=await observeCurrentProcessIdentity(stored.marker.pid);
96
+ if(!observed) return {status:'stale',live:false,reason:'process_unobservable',marker:stored.marker,marker_sha256:stored.raw_sha256};
97
+ if(observed.creation_time_utc!==new Date(stored.marker.creation_time_utc).toISOString()) {
98
+ return {status:'stale',live:false,reason:'pid_reused',marker:stored.marker,observation:observed,marker_sha256:stored.raw_sha256};
99
+ }
100
+ if(!samePath(observed.image_path,stored.marker.image_path)||observed.image_sha256!==stored.marker.image_sha256) {
101
+ return {status:'stale',live:false,reason:'identity_mismatch',marker:stored.marker,observation:observed,marker_sha256:stored.raw_sha256};
102
+ }
103
+ return {status:'owned',live:true,reason:'live_verified_owner',marker:stored.marker,observation:observed,marker_sha256:stored.raw_sha256};
104
+ }
105
+
106
+ export async function claimSupervisor(options={}){
107
+ const markerPath=assertOptions(options);
108
+ const marker=await currentMarker();
109
+ await mkdir(path.dirname(markerPath),{recursive:true});
110
+ try {
111
+ await writeFile(markerPath,`${JSON.stringify(marker)}\n`,{flag:'wx',mode:0o600});
112
+ } catch(error){
113
+ if(error?.code==='EEXIST') throw new Error('supervisor owner marker already exists; takeover required');
114
+ throw error;
115
+ }
116
+ return {status:'claimed',instance_nonce:marker.instance_nonce,marker};
117
+ }
118
+
119
+ export async function takeoverSupervisor(options={}){
120
+ const markerPath=assertOptions(options);
121
+ const prior=await observeSupervisor({markerPath});
122
+ if(prior.live&&prior.reason==='live_verified_owner') throw new Error('supervisor takeover refused: live verified owner');
123
+ if(prior.reason==='no_owner') return claimSupervisor({markerPath});
124
+ const marker=await currentMarker();
125
+ const before=await readMarker(markerPath);
126
+ if(!before.exists||before.raw_sha256!==prior.marker_sha256) throw new Error('supervisor ownership changed during takeover');
127
+ const temp=path.join(path.dirname(markerPath),`.${path.basename(markerPath)}.${process.pid}.${randomBytes(8).toString('hex')}.tmp`);
128
+ try {
129
+ await writeFile(temp,`${JSON.stringify(marker)}\n`,{flag:'wx',mode:0o600});
130
+ const check=await readMarker(markerPath);
131
+ if(!check.exists||check.raw_sha256!==prior.marker_sha256) throw new Error('supervisor ownership changed during takeover');
132
+ await rename(temp,markerPath);
133
+ } finally { await rm(temp,{force:true}).catch(()=>{}); }
134
+ return {status:'claimed',instance_nonce:marker.instance_nonce,marker,taken_over_reason:prior.reason};
135
+ }
136
+
137
+ export async function releaseSupervisor(options={}){
138
+ const markerPath=assertOptions(options);
139
+ if(typeof options.instanceNonce!=='string'||!HEX64.test(options.instanceNonce)) throw new Error('supervisor ownership nonce invalid');
140
+ const observed=await observeSupervisor({markerPath});
141
+ if(observed.reason==='no_owner') return {status:'absent'};
142
+ if(!observed.live||observed.reason!=='live_verified_owner') throw new Error(`supervisor ownership is not a live verified owner: ${observed.reason}`);
143
+ if(observed.marker.instance_nonce!==options.instanceNonce) throw new Error('supervisor ownership nonce mismatch');
144
+ if(observed.marker.pid!==process.pid) throw new Error('supervisor ownership belongs to another process');
145
+ const current=await observeCurrentProcessIdentity();
146
+ if(!current||current.creation_time_utc!==observed.observation.creation_time_utc||
147
+ !samePath(current.image_path,observed.observation.image_path)||current.image_sha256!==observed.observation.image_sha256) {
148
+ throw new Error('supervisor ownership current process identity mismatch');
149
+ }
150
+ const check=await readMarker(markerPath);
151
+ if(!check.exists||check.raw_sha256!==observed.marker_sha256) throw new Error('supervisor ownership changed before release');
152
+ await rm(markerPath,{force:false});
153
+ return {status:'released'};
154
+ }
155
+
156
+ export function validateSupervisorRecoveryRequest(request){
157
+ if(!request||typeof request!=='object'||Array.isArray(request)) throw new Error('supervisor recovery request invalid');
158
+ const keys=Object.keys(request);
159
+ if(keys.length!==1||keys[0]!=='operation') throw new Error('supervisor recovery request fields invalid');
160
+ if(typeof request.operation!=='string'||!RECOVERY_SET.has(request.operation)) throw new Error('supervisor recovery operation is not in allowlist');
161
+ return {operation:request.operation};
162
+ }
163
+
164
+ export async function runPinnedControllerOperation(options={}){
165
+ if(!options||typeof options!=='object'||Array.isArray(options)) throw new Error('supervisor controller options invalid');
166
+ const keys=Object.keys(options).sort();
167
+ if(JSON.stringify(keys)!==JSON.stringify(['controllerPath','controllerSha256','operation'])) {
168
+ throw new Error('supervisor controller options fields invalid');
169
+ }
170
+ if(typeof options.controllerPath!=='string'||options.controllerPath.length<3) throw new Error('supervisor controller path invalid');
171
+ if(typeof options.controllerSha256!=='string'||!HEX64.test(options.controllerSha256)) throw new Error('supervisor controller hash invalid');
172
+ const {operation}=validateSupervisorRecoveryRequest({operation:options.operation});
173
+ const controllerPath=path.resolve(options.controllerPath);
174
+ let bytes;
175
+ try { bytes=await readFile(controllerPath); }
176
+ catch(error){ throw new Error(`supervisor controller unavailable: ${error?.code??String(error)}`); }
177
+ const actual=sha256Bytes(bytes);
178
+ if(actual!==options.controllerSha256) throw new Error(`supervisor controller hash mismatch: expected ${options.controllerSha256}, found ${actual}`);
179
+ const shell=await powershellPath();
180
+ if(!shell) throw new Error('supervisor controller requires Windows PowerShell');
181
+ try {
182
+ const {stdout,stderr}=await execFileAsync(shell,['-NoProfile','-NonInteractive','-ExecutionPolicy','Bypass','-File',controllerPath,operation],{
183
+ windowsHide:true,timeout:120_000,maxBuffer:4*1024*1024,encoding:'utf8'
184
+ });
185
+ return {exit_code:0,stdout:String(stdout??''),stderr:String(stderr??'')};
186
+ } catch(error) {
187
+ return {exit_code:Number.isInteger(error?.code)?error.code:1,stdout:String(error?.stdout??''),stderr:String(error?.stderr??error?.message??'')};
188
+ }
189
+ }
190
+
191
+ function parseRecoveryStatus(stdout){
192
+ const text=String(stdout??'');
193
+ const state=text.match(/^DEADBYTE MCP\s*=\s*(ONLINE|PARKED|OFFLINE|DEGRADED)\s*$/mi)?.[1]??null;
194
+ const authority={
195
+ process:text.match(/^Process plane\s*:\s*(ARMED|DISARMED|UNCONFIGURED)\b/mi)?.[1]??null,
196
+ coding:text.match(/^Coding plane\s*:\s*(ARMED|DISARMED|UNCONFIGURED)\b/mi)?.[1]??null,
197
+ autonomous:text.match(/^Autonomous\s*:\s*(ARMED|DISARMED|UNCONFIGURED)\b/mi)?.[1]??null,
198
+ host:text.match(/^Host plane\s*:\s*(ARMED|DISARMED|UNCONFIGURED)\b/mi)?.[1]??null
199
+ };
200
+ return {runtime_state:state,authority};
201
+ }
202
+
203
+ export async function recoverManagedRuntime({runControllerOperation}={}){
204
+ if(typeof runControllerOperation!=='function') throw new Error('supervisor recovery requires controller runner');
205
+ const operations=['resume','disarmautonomous','disarmcoding','disarmprocess','disarmhost','status'];
206
+ const results=[];
207
+ for(const operation of operations){
208
+ const request=validateSupervisorRecoveryRequest({operation});
209
+ const result=await runControllerOperation(request);
210
+ if(!result||result.exit_code!==0) throw new Error(`supervisor recovery operation '${operation}' failed`);
211
+ results.push({operation,...result});
212
+ }
213
+ const observed=parseRecoveryStatus(results.at(-1)?.stdout);
214
+ if(observed.runtime_state!=='ONLINE') throw new Error(`supervisor recovery expected ONLINE, observed ${observed.runtime_state??'unknown'}`);
215
+ for(const [plane,value] of Object.entries(observed.authority)) {
216
+ if(value!=='DISARMED') throw new Error(`supervisor recovery requires ${plane} DISARMED, observed ${value??'unknown'}`);
217
+ }
218
+ return {status:'recovered',...observed,operations:results.map(item=>item.operation)};
219
+ }
220
+
221
+ export async function startLocalSupervisorHost({runtime,policy=runtime?.policy,markerPath,idleDelayMs=750,maxCycles=32,logger=console,continuous=true}={}){
222
+ if(!runtime||!policy) throw new Error('local supervisor host requires runtime + policy');
223
+ const observed=await observeSupervisor({markerPath});
224
+ const claim=observed.reason==='no_owner'
225
+ ? await claimSupervisor({markerPath})
226
+ : await takeoverSupervisor({markerPath});
227
+ let supervisor;
228
+ try {
229
+ supervisor=startAutonomousSupervisor({runtime,policy,idleDelayMs,maxCycles,logger,continuous});
230
+ } catch(error) {
231
+ await releaseSupervisor({markerPath,instanceNonce:claim.instance_nonce}).catch(()=>{});
232
+ throw error;
233
+ }
234
+ let stopped=false;
235
+ return Object.freeze({
236
+ marker_path:path.resolve(markerPath),instance_nonce:claim.instance_nonce,supervisor,
237
+ get running(){ return !stopped&&supervisor.running; },
238
+ async scanNow(){ if(stopped) throw new Error('local supervisor host stopped'); return supervisor.scanNow(); },
239
+ async stop(){
240
+ if(stopped) return {status:'stopped'};
241
+ stopped=true;
242
+ await supervisor.stop();
243
+ await releaseSupervisor({markerPath,instanceNonce:claim.instance_nonce});
244
+ return {status:'stopped'};
245
+ }
246
+ });
247
+ }
248
+
249
+ export const AUTONOMOUS_SUPERVISOR_RECOVERY_OPERATIONS=RECOVERY_OPERATIONS;