@eyeauras/insight-cli 0.8.4 → 0.9.1

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 (609) hide show
  1. package/.cli-package-build.json +1 -1
  2. package/README.md +16 -23
  3. package/SKILL.md +6 -44
  4. package/dist/src/activity-audit.d.ts +33 -46
  5. package/dist/src/activity-audit.js +120 -195
  6. package/dist/src/analysis-default.d.ts +10 -2
  7. package/dist/src/analysis-default.js +62 -47
  8. package/dist/src/analysis-storage.d.ts +13 -13
  9. package/dist/src/analysis-storage.js +127 -258
  10. package/dist/src/artifacts.d.ts +5 -1
  11. package/dist/src/artifacts.js +31 -46
  12. package/dist/src/audit-commands.d.ts +6 -1
  13. package/dist/src/audit-commands.js +9 -2
  14. package/dist/src/audit-retention.d.ts +5 -23
  15. package/dist/src/audit-retention.js +37 -150
  16. package/dist/src/binary.js +4 -13
  17. package/dist/src/budgets.d.ts +2 -2
  18. package/dist/src/budgets.js +7 -9
  19. package/dist/src/capture.js +17 -30
  20. package/dist/src/cli.d.ts +9 -4
  21. package/dist/src/cli.js +288 -473
  22. package/dist/src/code-references.d.ts +2 -13
  23. package/dist/src/code-references.js +7 -99
  24. package/dist/src/context-diagnostics.d.ts +1 -23
  25. package/dist/src/context-diagnostics.js +1 -83
  26. package/dist/src/core/coordinator.d.ts +298 -0
  27. package/dist/src/core/coordinator.js +591 -0
  28. package/dist/src/core/layout.d.ts +51 -0
  29. package/dist/src/core/layout.js +55 -0
  30. package/dist/src/core/legacy-import.d.ts +55 -0
  31. package/dist/src/core/legacy-import.js +193 -0
  32. package/dist/src/cross-results.d.ts +3 -3
  33. package/dist/src/cross-results.js +4 -42
  34. package/dist/src/cross.js +2 -3
  35. package/dist/src/debugger-results.d.ts +1 -6
  36. package/dist/src/debugger-results.js +21 -153
  37. package/dist/src/debugger.d.ts +21 -11
  38. package/dist/src/debugger.js +106 -168
  39. package/dist/src/decode-results.d.ts +2 -1
  40. package/dist/src/decode-results.js +4 -20
  41. package/dist/src/diagnostic-error.d.ts +1 -1
  42. package/dist/src/diagnostic-error.js +4 -23
  43. package/dist/src/die.js +1 -23
  44. package/dist/src/dnspy-runtime.js +5 -12
  45. package/dist/src/dnspy.js +13 -28
  46. package/dist/src/dotnet-diagnostics.js +1 -1
  47. package/dist/src/extensions.d.ts +2 -3
  48. package/dist/src/extensions.js +14 -91
  49. package/dist/src/frida-worker.js +0 -20
  50. package/dist/src/frida.js +3 -26
  51. package/dist/src/function-boundaries.d.ts +2 -2
  52. package/dist/src/function-boundaries.js +9 -61
  53. package/dist/src/function-entries.d.ts +2 -2
  54. package/dist/src/function-entries.js +6 -36
  55. package/dist/src/function-inspection.d.ts +2 -2
  56. package/dist/src/function-inspection.js +17 -33
  57. package/dist/src/function-results.d.ts +1 -3
  58. package/dist/src/function-results.js +2 -13
  59. package/dist/src/hub/admin.d.ts +101 -0
  60. package/dist/src/hub/admin.js +314 -0
  61. package/dist/src/hub/autostart.d.ts +111 -0
  62. package/dist/src/hub/autostart.js +207 -0
  63. package/dist/src/hub/bundle.d.ts +33 -0
  64. package/dist/src/hub/bundle.js +25 -0
  65. package/dist/src/hub/client.d.ts +90 -0
  66. package/dist/src/hub/client.js +256 -0
  67. package/dist/src/hub/commands.d.ts +13 -0
  68. package/dist/src/hub/commands.js +280 -0
  69. package/dist/src/hub/contract.d.ts +87 -0
  70. package/dist/src/hub/contract.js +3 -0
  71. package/dist/src/hub/extensions.d.ts +41 -0
  72. package/dist/src/hub/extensions.js +3 -0
  73. package/dist/src/hub/ghidra.d.ts +70 -0
  74. package/dist/src/hub/ghidra.js +197 -0
  75. package/dist/src/hub/index.d.ts +6 -0
  76. package/dist/src/hub/index.js +7 -0
  77. package/dist/src/{work/store.d.ts → hub/ledger-store.d.ts} +57 -94
  78. package/dist/src/hub/ledger-store.js +919 -0
  79. package/dist/src/hub/ledger.d.ts +4 -0
  80. package/dist/src/hub/ledger.js +173 -0
  81. package/dist/src/hub/lock.d.ts +7 -0
  82. package/dist/src/hub/lock.js +53 -0
  83. package/dist/src/hub/repository.d.ts +45 -0
  84. package/dist/src/hub/repository.js +130 -0
  85. package/dist/src/hub/server.d.ts +86 -0
  86. package/dist/src/hub/server.js +414 -0
  87. package/dist/src/hub/settings.d.ts +36 -0
  88. package/dist/src/hub/settings.js +112 -0
  89. package/dist/src/hub/storage.d.ts +13 -0
  90. package/dist/src/hub/storage.js +46 -0
  91. package/dist/src/hub/store.d.ts +75 -0
  92. package/dist/src/hub/store.js +188 -0
  93. package/dist/src/ilspy.js +1 -1
  94. package/dist/src/internal-timing.d.ts +2 -9
  95. package/dist/src/internal-timing.js +2 -95
  96. package/dist/src/lldb.js +3 -15
  97. package/dist/src/llvm.js +0 -9
  98. package/dist/src/managed-heap.js +3 -7
  99. package/dist/src/managed-metadata.js +2 -5
  100. package/dist/src/memory-inputs.d.ts +1 -4
  101. package/dist/src/memory-inputs.js +10 -40
  102. package/dist/src/mitmproxy.d.ts +35 -4
  103. package/dist/src/mitmproxy.js +59 -40
  104. package/dist/src/model.d.ts +0 -73
  105. package/dist/src/model.js +0 -45
  106. package/dist/src/mutations.d.ts +1 -1
  107. package/dist/src/mutations.js +5 -10
  108. package/dist/src/native/contract.d.ts +130 -0
  109. package/dist/src/native/ghidra.d.ts +58 -0
  110. package/dist/src/native/ghidra.js +77 -0
  111. package/dist/src/native/host.d.ts +71 -0
  112. package/dist/src/native/host.js +265 -0
  113. package/dist/src/native/index.d.ts +13 -0
  114. package/dist/src/native/index.js +19 -0
  115. package/dist/src/native/jvm.d.ts +54 -0
  116. package/dist/src/native/jvm.js +47 -0
  117. package/dist/src/native/worker.d.ts +70 -0
  118. package/dist/src/native/worker.js +240 -0
  119. package/dist/src/native-inputs.d.ts +9 -14
  120. package/dist/src/native-inputs.js +22 -110
  121. package/dist/src/native-merge-patches.d.ts +2 -2
  122. package/dist/src/native-merge-patches.js +14 -14
  123. package/dist/src/persistent-client.js +53 -25
  124. package/dist/src/procmon.js +17 -31
  125. package/dist/src/program-files.d.ts +42 -0
  126. package/dist/src/program-files.js +148 -0
  127. package/dist/src/queries.js +2 -15
  128. package/dist/src/query-policy.d.ts +0 -2
  129. package/dist/src/query-policy.js +1 -14
  130. package/dist/src/research.d.ts +59 -238
  131. package/dist/src/research.js +212 -906
  132. package/dist/src/runtime-identity.d.ts +8 -0
  133. package/dist/src/runtime-identity.js +26 -0
  134. package/dist/src/runtime-manager.d.ts +1 -11
  135. package/dist/src/runtime-manager.js +10 -145
  136. package/dist/src/runtime-selection.d.ts +1 -1
  137. package/dist/src/runtime-selection.js +5 -37
  138. package/dist/src/saved-materials.js +8 -51
  139. package/dist/src/scripts.d.ts +1 -1
  140. package/dist/src/scripts.js +15 -15
  141. package/dist/src/sdk-contracts.js +2 -2
  142. package/dist/src/sdk.js +8 -8
  143. package/dist/src/sevenzip.js +1 -3
  144. package/dist/src/strace.js +0 -3
  145. package/dist/src/string-anchors.d.ts +2 -3
  146. package/dist/src/string-anchors.js +8 -101
  147. package/dist/src/text-window.d.ts +5 -4
  148. package/dist/src/text-window.js +4 -4
  149. package/dist/src/tool-runtime/archives.d.ts +1 -1
  150. package/dist/src/tool-runtime/archives.js +11 -20
  151. package/dist/src/tool-runtime/catalog.js +2 -5
  152. package/dist/src/tool-runtime/commands.js +1 -3
  153. package/dist/src/tool-runtime/deadline.js +2 -7
  154. package/dist/src/tool-runtime/definition.js +1 -31
  155. package/dist/src/tool-runtime/identity.js +6 -87
  156. package/dist/src/tool-runtime/installer.d.ts +2 -6
  157. package/dist/src/tool-runtime/installer.js +14 -76
  158. package/dist/src/tool-runtime/java-arguments.js +4 -10
  159. package/dist/src/tool-runtime/launch-worker.js +2 -8
  160. package/dist/src/tool-runtime/run.d.ts +2 -0
  161. package/dist/src/tool-runtime/run.js +20 -8
  162. package/dist/src/tool-runtime/store.d.ts +3 -3
  163. package/dist/src/tool-runtime/store.js +21 -83
  164. package/dist/src/tool-runtime/supervisor.d.ts +6 -11
  165. package/dist/src/tool-runtime/supervisor.js +155 -214
  166. package/dist/src/tool-runtime/windows-helper.d.ts +5 -0
  167. package/dist/src/tool-runtime/windows-helper.js +13 -0
  168. package/dist/src/tool-runtime/windows-job.d.ts +5 -5
  169. package/dist/src/tool-runtime/windows-job.js +13 -31
  170. package/dist/src/tshark.js +14 -27
  171. package/dist/src/ui-results.d.ts +3 -2
  172. package/dist/src/ui-results.js +16 -53
  173. package/dist/src/ui.d.ts +12 -13
  174. package/dist/src/ui.js +32 -70
  175. package/dist/src/version-tracking.d.ts +25 -39
  176. package/dist/src/version-tracking.js +70 -174
  177. package/dist/src/windbg.d.ts +1 -1
  178. package/dist/src/windbg.js +2 -8
  179. package/dist/src/work/client.d.ts +63 -0
  180. package/dist/src/work/client.js +163 -0
  181. package/dist/src/work/commands.d.ts +3 -1
  182. package/dist/src/work/commands.js +158 -184
  183. package/dist/src/work/dashboard.d.ts +2 -2
  184. package/dist/src/work/dashboard.js +7 -8
  185. package/dist/src/work/legacy.d.ts +8 -0
  186. package/dist/src/work/legacy.js +70 -0
  187. package/dist/src/work/model.d.ts +0 -3
  188. package/dist/src/work/model.js +0 -10
  189. package/dist/src/work/timing.d.ts +3 -3
  190. package/dist/src/work/timing.js +21 -25
  191. package/dist/src/workspace.d.ts +4 -250
  192. package/dist/src/workspace.js +11 -699
  193. package/node_modules/@eyeauras/cli-factory/README.md +6 -0
  194. package/node_modules/@eyeauras/cli-factory/dist/src/cli.d.ts.map +1 -1
  195. package/node_modules/@eyeauras/cli-factory/dist/src/cli.js +76 -28
  196. package/node_modules/@eyeauras/cli-factory/dist/src/cli.js.map +1 -1
  197. package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts +1 -1
  198. package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts.map +1 -1
  199. package/node_modules/@eyeauras/cli-factory/dist/src/command.js +1 -0
  200. package/node_modules/@eyeauras/cli-factory/dist/src/command.js.map +1 -1
  201. package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts +1 -1
  202. package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts.map +1 -1
  203. package/node_modules/@eyeauras/cli-factory/dist/src/errors.js +18 -6
  204. package/node_modules/@eyeauras/cli-factory/dist/src/errors.js.map +1 -1
  205. package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts +44 -0
  206. package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts.map +1 -0
  207. package/node_modules/@eyeauras/cli-factory/dist/src/{profile-file.js → file-publication.js} +41 -113
  208. package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.js.map +1 -0
  209. package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts +5 -0
  210. package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts.map +1 -0
  211. package/node_modules/@eyeauras/cli-factory/dist/src/help.js +17 -0
  212. package/node_modules/@eyeauras/cli-factory/dist/src/help.js.map +1 -0
  213. package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts +9 -4
  214. package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts.map +1 -1
  215. package/node_modules/@eyeauras/cli-factory/dist/src/index.js +5 -2
  216. package/node_modules/@eyeauras/cli-factory/dist/src/index.js.map +1 -1
  217. package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.d.ts.map +1 -1
  218. package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js +11 -18
  219. package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js.map +1 -1
  220. package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts +10 -0
  221. package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts.map +1 -0
  222. package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js +69 -0
  223. package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js.map +1 -0
  224. package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts +3 -1
  225. package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts.map +1 -1
  226. package/node_modules/@eyeauras/cli-factory/dist/src/output.js +74 -14
  227. package/node_modules/@eyeauras/cli-factory/dist/src/output.js.map +1 -1
  228. package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts +3 -0
  229. package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts.map +1 -0
  230. package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js +9 -0
  231. package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js.map +1 -0
  232. package/node_modules/@eyeauras/cli-factory/dist/src/permissions.d.ts.map +1 -1
  233. package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js +3 -1
  234. package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js.map +1 -1
  235. package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts +16 -0
  236. package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts.map +1 -0
  237. package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js +83 -0
  238. package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js.map +1 -0
  239. package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts +5 -0
  240. package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts.map +1 -1
  241. package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts +49 -7
  242. package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts.map +1 -1
  243. package/node_modules/@eyeauras/cli-factory/dist/src/view.js +83 -6
  244. package/node_modules/@eyeauras/cli-factory/dist/src/view.js.map +1 -1
  245. package/node_modules/@eyeauras/cli-factory/package.json +1 -1
  246. package/node_modules/@eyeauras/cli-factory-ipc/dist/cli-host.proto +19 -19
  247. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts +7 -1
  248. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts.map +1 -1
  249. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js +9 -4
  250. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js.map +1 -1
  251. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.d.ts.map +1 -1
  252. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js +5 -4
  253. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js.map +1 -1
  254. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts +11 -1
  255. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts.map +1 -1
  256. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js +85 -57
  257. package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js.map +1 -1
  258. package/node_modules/@eyeauras/cli-factory-ipc/package.json +2 -2
  259. package/package.json +4 -5
  260. package/references/native/InsightAnalyzerOptions.java +10 -0
  261. package/references/native/InsightAnchorScan.java +1 -11
  262. package/references/native/InsightCodeReferences.java +2 -3
  263. package/references/native/InsightCopyType.java +24 -0
  264. package/references/native/InsightFunctionBoundaries.java +0 -1
  265. package/references/native/InsightFunctionDatabases.java +20 -16
  266. package/references/native/InsightHelperCall.java +17 -0
  267. package/references/native/InsightHubServer.java +214 -0
  268. package/references/native/InsightNativeHost.java +112 -0
  269. package/references/native/InsightPlugins.java +0 -1
  270. package/references/native/InsightPythonWheels.java +3 -2
  271. package/references/native/InsightResearchQueries.java +3 -4
  272. package/references/native/InsightResearchView.java +4 -10
  273. package/references/native/InsightSdkFiles.java +7 -15
  274. package/references/native/InsightSdkScript.java +1 -4
  275. package/references/native/InsightSdkTools.java +36 -97
  276. package/references/native/InsightSdkTypes.java +13 -43
  277. package/references/native/InsightStringAnchors.java +1 -3
  278. package/references/native/InsightTraceState.java +13 -96
  279. package/references/native/InsightTraceTools.java +3 -5
  280. package/references/native/InsightVersionTracking.java +0 -6
  281. package/references/native/{HeadlessProgramMergeManager.java → InsightWcMerge.java} +17 -24
  282. package/references/native/InsightWcOps.java +449 -0
  283. package/references/native/InsightWcWorker.java +142 -0
  284. package/references/native/NATIVE-MERGE-NOTICE.txt +4 -8
  285. package/runtime/GhidraMCP-7.0.0.jar +0 -0
  286. package/runtime/managed/insight-heap/README.md +3 -3
  287. package/runtime/managed/insight-managed/README.md +3 -3
  288. package/runtime/native/binary/README.md +5 -4
  289. package/runtime/native/windows/DirectoryAlias.cs +24 -0
  290. package/runtime/native/windows/Insight.Windows.csproj +27 -0
  291. package/runtime/native/windows/Native.cs +36 -0
  292. package/runtime/native/windows/OwnedJob.cs +86 -0
  293. package/runtime/native/windows/Program.cs +50 -0
  294. package/runtime/native/windows/RegistryRedirect.cs +42 -0
  295. package/runtime/native/windows/insight-windows-x64.exe +0 -0
  296. package/runtime/native/windows/packages.lock.json +35 -0
  297. package/runtime/native/windows/provenance.json +17 -0
  298. package/runtime/research-view.provenance.json +6 -7
  299. package/runtime/toolbox.json +33 -114
  300. package/skill-bundle/insight-artifacts/SKILL.md +5 -19
  301. package/skill-bundle/insight-binary/SKILL.md +5 -35
  302. package/skill-bundle/insight-capture/SKILL.md +5 -45
  303. package/skill-bundle/insight-cli/SKILL.md +6 -44
  304. package/skill-bundle/insight-die/SKILL.md +5 -38
  305. package/skill-bundle/insight-dnspy/SKILL.md +5 -54
  306. package/skill-bundle/insight-dotnet-dump/SKILL.md +5 -35
  307. package/skill-bundle/insight-dotnet-stack/SKILL.md +5 -28
  308. package/skill-bundle/insight-dotnet-trace/SKILL.md +5 -34
  309. package/skill-bundle/insight-frida/SKILL.md +5 -56
  310. package/skill-bundle/insight-ghidra/SKILL.md +14 -113
  311. package/skill-bundle/insight-ilspy/SKILL.md +5 -34
  312. package/skill-bundle/insight-interop/SKILL.md +5 -43
  313. package/skill-bundle/insight-lldb/SKILL.md +5 -43
  314. package/skill-bundle/insight-llvm/SKILL.md +5 -45
  315. package/skill-bundle/insight-managed-heap/SKILL.md +5 -32
  316. package/skill-bundle/insight-managed-metadata/SKILL.md +5 -41
  317. package/skill-bundle/insight-mitmproxy/SKILL.md +5 -51
  318. package/skill-bundle/insight-overview/SKILL.md +5 -68
  319. package/skill-bundle/insight-procmon/SKILL.md +5 -38
  320. package/skill-bundle/insight-re/SKILL.md +10 -127
  321. package/skill-bundle/insight-sevenzip/SKILL.md +5 -31
  322. package/skill-bundle/insight-strace/SKILL.md +5 -35
  323. package/skill-bundle/insight-tshark/SKILL.md +5 -38
  324. package/skill-bundle/insight-windbg/SKILL.md +5 -35
  325. package/skill-bundle/manifest.json +1 -1
  326. package/skills/insight-artifacts/SKILL.md +5 -19
  327. package/skills/insight-binary/SKILL.md +5 -35
  328. package/skills/insight-capture/SKILL.md +5 -45
  329. package/skills/insight-die/SKILL.md +5 -38
  330. package/skills/insight-dnspy/SKILL.md +5 -54
  331. package/skills/insight-dotnet-dump/SKILL.md +5 -35
  332. package/skills/insight-dotnet-stack/SKILL.md +5 -28
  333. package/skills/insight-dotnet-trace/SKILL.md +5 -34
  334. package/skills/insight-frida/SKILL.md +5 -56
  335. package/skills/insight-ghidra/SKILL.md +14 -113
  336. package/skills/insight-ilspy/SKILL.md +5 -34
  337. package/skills/insight-interop/SKILL.md +5 -43
  338. package/skills/insight-lldb/SKILL.md +5 -43
  339. package/skills/insight-llvm/SKILL.md +5 -45
  340. package/skills/insight-managed-heap/SKILL.md +5 -32
  341. package/skills/insight-managed-metadata/SKILL.md +5 -41
  342. package/skills/insight-mitmproxy/SKILL.md +5 -51
  343. package/skills/insight-overview/SKILL.md +5 -68
  344. package/skills/insight-procmon/SKILL.md +5 -38
  345. package/skills/insight-re/SKILL.md +10 -127
  346. package/skills/insight-sevenzip/SKILL.md +5 -31
  347. package/skills/insight-strace/SKILL.md +5 -35
  348. package/skills/insight-tshark/SKILL.md +5 -38
  349. package/skills/insight-windbg/SKILL.md +5 -35
  350. package/dist/src/administration-results.d.ts +0 -1
  351. package/dist/src/administration-results.js +0 -84
  352. package/dist/src/administration.d.ts +0 -14
  353. package/dist/src/administration.js +0 -134
  354. package/dist/src/archive-contract.d.ts +0 -6
  355. package/dist/src/archive-contract.js +0 -108
  356. package/dist/src/archive.d.ts +0 -12
  357. package/dist/src/archive.js +0 -116
  358. package/dist/src/comment-effects.d.ts +0 -3
  359. package/dist/src/comment-effects.js +0 -55
  360. package/dist/src/context-credential.d.ts +0 -18
  361. package/dist/src/context-credential.js +0 -44
  362. package/dist/src/contexts.d.ts +0 -387
  363. package/dist/src/contexts.js +0 -2805
  364. package/dist/src/coordinator.d.ts +0 -41
  365. package/dist/src/coordinator.js +0 -160
  366. package/dist/src/cross-peer.d.ts +0 -20
  367. package/dist/src/cross-peer.js +0 -53
  368. package/dist/src/data-effects.d.ts +0 -3
  369. package/dist/src/data-effects.js +0 -103
  370. package/dist/src/debugger-caller.d.ts +0 -17
  371. package/dist/src/debugger-caller.js +0 -129
  372. package/dist/src/debugger-launch.d.ts +0 -2
  373. package/dist/src/debugger-launch.js +0 -17
  374. package/dist/src/debugger-supervisor.js +0 -179
  375. package/dist/src/directory-identity.d.ts +0 -6
  376. package/dist/src/directory-identity.js +0 -45
  377. package/dist/src/documentation-effects.d.ts +0 -5
  378. package/dist/src/documentation-effects.js +0 -56
  379. package/dist/src/function-effects.d.ts +0 -4
  380. package/dist/src/function-effects.js +0 -112
  381. package/dist/src/ghidra-processes.d.ts +0 -6
  382. package/dist/src/ghidra-processes.js +0 -138
  383. package/dist/src/ghidra.d.ts +0 -50
  384. package/dist/src/ghidra.js +0 -468
  385. package/dist/src/initial-model.d.ts +0 -7
  386. package/dist/src/initial-model.js +0 -115
  387. package/dist/src/initial-progress.d.ts +0 -4
  388. package/dist/src/initial-progress.js +0 -74
  389. package/dist/src/inline-script.d.ts +0 -15
  390. package/dist/src/inline-script.js +0 -61
  391. package/dist/src/legacy-migration.d.ts +0 -37
  392. package/dist/src/legacy-migration.js +0 -238
  393. package/dist/src/lifecycle.d.ts +0 -77
  394. package/dist/src/lifecycle.js +0 -315
  395. package/dist/src/merge.d.ts +0 -29
  396. package/dist/src/merge.js +0 -66
  397. package/dist/src/mutation-effects.d.ts +0 -4
  398. package/dist/src/mutation-effects.js +0 -321
  399. package/dist/src/native-queries.d.ts +0 -2
  400. package/dist/src/native-queries.js +0 -24
  401. package/dist/src/native-service.d.ts +0 -40
  402. package/dist/src/native-service.js +0 -406
  403. package/dist/src/projects.d.ts +0 -31
  404. package/dist/src/projects.js +0 -302
  405. package/dist/src/prototype-cli.d.ts +0 -8
  406. package/dist/src/prototype-cli.js +0 -155
  407. package/dist/src/query-results.d.ts +0 -2
  408. package/dist/src/query-results.js +0 -224
  409. package/dist/src/research-view.d.ts +0 -6
  410. package/dist/src/research-view.js +0 -9
  411. package/dist/src/sdk-files.d.ts +0 -29
  412. package/dist/src/sdk-files.js +0 -249
  413. package/dist/src/server.d.ts +0 -102
  414. package/dist/src/server.js +0 -663
  415. package/dist/src/storage-gc.d.ts +0 -23
  416. package/dist/src/storage-gc.js +0 -600
  417. package/dist/src/store.d.ts +0 -33
  418. package/dist/src/store.js +0 -178
  419. package/dist/src/sync-policy.d.ts +0 -22
  420. package/dist/src/sync-policy.js +0 -129
  421. package/dist/src/timed-backend.d.ts +0 -3
  422. package/dist/src/timed-backend.js +0 -24
  423. package/dist/src/timing-report.d.ts +0 -32
  424. package/dist/src/timing-report.js +0 -74
  425. package/dist/src/tool-runtime/native-process-proof.d.ts +0 -2
  426. package/dist/src/tool-runtime/native-process-proof.js +0 -26
  427. package/dist/src/transport.d.ts +0 -60
  428. package/dist/src/transport.js +0 -223
  429. package/dist/src/unresolved-guidance.d.ts +0 -46
  430. package/dist/src/unresolved-guidance.js +0 -55
  431. package/dist/src/work/backup.d.ts +0 -66
  432. package/dist/src/work/backup.js +0 -446
  433. package/dist/src/work/store.js +0 -1107
  434. package/dist/src/worker-lease.d.ts +0 -17
  435. package/dist/src/worker-lease.js +0 -50
  436. package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts +0 -37
  437. package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts.map +0 -1
  438. package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.js.map +0 -1
  439. package/references/InsightRepositoryProbe.java +0 -55
  440. package/references/administration.md +0 -34
  441. package/references/agent-execution.md +0 -36
  442. package/references/agent-setup.md +0 -60
  443. package/references/archive.md +0 -32
  444. package/references/artifacts.md +0 -52
  445. package/references/debugger.md +0 -64
  446. package/references/extensions-and-sync.md +0 -125
  447. package/references/ilspy.md +0 -33
  448. package/references/managed-runtime.md +0 -162
  449. package/references/native/InsightArchivePayloads.java +0 -36
  450. package/references/native/InsightBlockTransfer.java +0 -57
  451. package/references/native/InsightGuiMain.java +0 -33
  452. package/references/native/InsightHeadlessMain.java +0 -18
  453. package/references/native/InsightImportProgress.java +0 -60
  454. package/references/native/InsightInitialImport.java +0 -48
  455. package/references/native/InsightInitialJournal.java +0 -57
  456. package/references/native/InsightInitialPublication.java +0 -142
  457. package/references/native/InsightInitialRecovery.java +0 -131
  458. package/references/native/InsightInlineExecutor.java +0 -143
  459. package/references/native/InsightInlineScript.java +0 -14
  460. package/references/native/InsightNativeCheckout.java +0 -487
  461. package/references/native/InsightNativeFingerprint.java +0 -80
  462. package/references/native/InsightNativeMigration.java +0 -155
  463. package/references/native/InsightNativeRead.java +0 -80
  464. package/references/native/InsightNativeReceipt.java +0 -31
  465. package/references/native/InsightNativeService.java +0 -43
  466. package/references/native/InsightNativeView.java +0 -40
  467. package/references/native/InsightOfflineAuthenticator.java +0 -20
  468. package/references/native/InsightOwnedScripts.java +0 -170
  469. package/references/native/InsightProjectFiles.java +0 -92
  470. package/references/native/InsightPublicationRecovery.java +0 -63
  471. package/references/native/InsightServerAdministration.java +0 -82
  472. package/references/native/InsightServerInit.java +0 -62
  473. package/references/native/InsightServerMain.java +0 -43
  474. package/references/native/InsightServerProbe.java +0 -29
  475. package/references/native/InsightSnapshotFields.java +0 -74
  476. package/references/native/InsightSnapshotInspect.java +0 -191
  477. package/references/native/InsightSnapshotPublisher.java +0 -123
  478. package/references/native/InsightStopDebugger.java +0 -20
  479. package/references/native/InsightTraceInspect.java +0 -24
  480. package/references/native/InsightWorkerLease.java +0 -132
  481. package/references/native-workflows.md +0 -124
  482. package/references/persistent-client.mjs +0 -147
  483. package/references/persistent.md +0 -90
  484. package/references/query-semantics.md +0 -109
  485. package/references/recovery.md +0 -235
  486. package/references/research.md +0 -296
  487. package/references/setup.md +0 -135
  488. package/references/sparse-navigation.md +0 -173
  489. package/references/storage.md +0 -139
  490. package/references/work-tracking.md +0 -261
  491. package/runtime/native/file-version.ps1 +0 -7
  492. package/runtime/native/mitmproxy/bridge.py +0 -180
  493. package/runtime/native/windows-job/DirectoryAlias.cs +0 -24
  494. package/runtime/native/windows-job/Insight.WindowsJob.csproj +0 -1
  495. package/runtime/native/windows-job/Insight.WindowsJob.dll +0 -0
  496. package/runtime/native/windows-job/OwnedJob.cs +0 -79
  497. package/runtime/native/windows-job/RegistryRedirect.cs +0 -45
  498. package/runtime/native/windows-job/packages.lock.json +0 -21
  499. package/runtime/native/windows-job/provenance.json +0 -16
  500. package/runtime/native/windows-job/windows-job.ps1 +0 -8
  501. package/skill-bundle/insight-artifacts/references/agent-execution.md +0 -36
  502. package/skill-bundle/insight-artifacts/references/artifacts.md +0 -52
  503. package/skill-bundle/insight-artifacts/references/recovery.md +0 -235
  504. package/skill-bundle/insight-artifacts/references/storage.md +0 -139
  505. package/skill-bundle/insight-binary/references/agent-execution.md +0 -36
  506. package/skill-bundle/insight-capture/references/agent-execution.md +0 -36
  507. package/skill-bundle/insight-cli/references/agent-execution.md +0 -36
  508. package/skill-bundle/insight-cli/references/agent-setup.md +0 -60
  509. package/skill-bundle/insight-cli/references/archive.md +0 -32
  510. package/skill-bundle/insight-cli/references/managed-runtime.md +0 -162
  511. package/skill-bundle/insight-cli/references/persistent-client.mjs +0 -147
  512. package/skill-bundle/insight-cli/references/persistent.md +0 -90
  513. package/skill-bundle/insight-cli/references/recovery.md +0 -235
  514. package/skill-bundle/insight-cli/references/setup.md +0 -135
  515. package/skill-bundle/insight-cli/references/storage.md +0 -139
  516. package/skill-bundle/insight-die/references/agent-execution.md +0 -36
  517. package/skill-bundle/insight-dnspy/references/agent-execution.md +0 -36
  518. package/skill-bundle/insight-dotnet-dump/references/agent-execution.md +0 -36
  519. package/skill-bundle/insight-dotnet-stack/references/agent-execution.md +0 -36
  520. package/skill-bundle/insight-dotnet-trace/references/agent-execution.md +0 -36
  521. package/skill-bundle/insight-frida/references/agent-execution.md +0 -36
  522. package/skill-bundle/insight-ghidra/references/administration.md +0 -34
  523. package/skill-bundle/insight-ghidra/references/agent-execution.md +0 -36
  524. package/skill-bundle/insight-ghidra/references/archive.md +0 -32
  525. package/skill-bundle/insight-ghidra/references/artifacts.md +0 -52
  526. package/skill-bundle/insight-ghidra/references/debugger.md +0 -64
  527. package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +0 -125
  528. package/skill-bundle/insight-ghidra/references/managed-runtime.md +0 -162
  529. package/skill-bundle/insight-ghidra/references/native-workflows.md +0 -124
  530. package/skill-bundle/insight-ghidra/references/persistent-client.mjs +0 -147
  531. package/skill-bundle/insight-ghidra/references/persistent.md +0 -90
  532. package/skill-bundle/insight-ghidra/references/query-semantics.md +0 -109
  533. package/skill-bundle/insight-ghidra/references/recovery.md +0 -235
  534. package/skill-bundle/insight-ghidra/references/research.md +0 -296
  535. package/skill-bundle/insight-ghidra/references/setup.md +0 -135
  536. package/skill-bundle/insight-ghidra/references/sparse-navigation.md +0 -173
  537. package/skill-bundle/insight-ghidra/references/storage.md +0 -139
  538. package/skill-bundle/insight-ilspy/references/agent-execution.md +0 -36
  539. package/skill-bundle/insight-ilspy/references/ilspy.md +0 -33
  540. package/skill-bundle/insight-interop/references/agent-execution.md +0 -36
  541. package/skill-bundle/insight-lldb/references/agent-execution.md +0 -36
  542. package/skill-bundle/insight-llvm/references/agent-execution.md +0 -36
  543. package/skill-bundle/insight-managed-heap/references/agent-execution.md +0 -36
  544. package/skill-bundle/insight-managed-metadata/references/agent-execution.md +0 -36
  545. package/skill-bundle/insight-mitmproxy/references/agent-execution.md +0 -36
  546. package/skill-bundle/insight-overview/references/agent-execution.md +0 -36
  547. package/skill-bundle/insight-procmon/references/agent-execution.md +0 -36
  548. package/skill-bundle/insight-re/references/agent-execution.md +0 -36
  549. package/skill-bundle/insight-re/references/artifacts.md +0 -52
  550. package/skill-bundle/insight-re/references/persistent-client.mjs +0 -147
  551. package/skill-bundle/insight-re/references/persistent.md +0 -90
  552. package/skill-bundle/insight-re/references/recovery.md +0 -235
  553. package/skill-bundle/insight-re/references/storage.md +0 -139
  554. package/skill-bundle/insight-re/references/work-tracking.md +0 -261
  555. package/skill-bundle/insight-sevenzip/references/agent-execution.md +0 -36
  556. package/skill-bundle/insight-strace/references/agent-execution.md +0 -36
  557. package/skill-bundle/insight-tshark/references/agent-execution.md +0 -36
  558. package/skill-bundle/insight-windbg/references/agent-execution.md +0 -36
  559. package/skills/insight-artifacts/references/agent-execution.md +0 -36
  560. package/skills/insight-artifacts/references/artifacts.md +0 -52
  561. package/skills/insight-artifacts/references/recovery.md +0 -235
  562. package/skills/insight-artifacts/references/storage.md +0 -139
  563. package/skills/insight-binary/references/agent-execution.md +0 -36
  564. package/skills/insight-capture/references/agent-execution.md +0 -36
  565. package/skills/insight-die/references/agent-execution.md +0 -36
  566. package/skills/insight-dnspy/references/agent-execution.md +0 -36
  567. package/skills/insight-dotnet-dump/references/agent-execution.md +0 -36
  568. package/skills/insight-dotnet-stack/references/agent-execution.md +0 -36
  569. package/skills/insight-dotnet-trace/references/agent-execution.md +0 -36
  570. package/skills/insight-frida/references/agent-execution.md +0 -36
  571. package/skills/insight-ghidra/references/administration.md +0 -34
  572. package/skills/insight-ghidra/references/agent-execution.md +0 -36
  573. package/skills/insight-ghidra/references/archive.md +0 -32
  574. package/skills/insight-ghidra/references/artifacts.md +0 -52
  575. package/skills/insight-ghidra/references/debugger.md +0 -64
  576. package/skills/insight-ghidra/references/extensions-and-sync.md +0 -125
  577. package/skills/insight-ghidra/references/managed-runtime.md +0 -162
  578. package/skills/insight-ghidra/references/native-workflows.md +0 -124
  579. package/skills/insight-ghidra/references/persistent-client.mjs +0 -147
  580. package/skills/insight-ghidra/references/persistent.md +0 -90
  581. package/skills/insight-ghidra/references/query-semantics.md +0 -109
  582. package/skills/insight-ghidra/references/recovery.md +0 -235
  583. package/skills/insight-ghidra/references/research.md +0 -296
  584. package/skills/insight-ghidra/references/setup.md +0 -135
  585. package/skills/insight-ghidra/references/sparse-navigation.md +0 -173
  586. package/skills/insight-ghidra/references/storage.md +0 -139
  587. package/skills/insight-ilspy/references/agent-execution.md +0 -36
  588. package/skills/insight-ilspy/references/ilspy.md +0 -33
  589. package/skills/insight-interop/references/agent-execution.md +0 -36
  590. package/skills/insight-lldb/references/agent-execution.md +0 -36
  591. package/skills/insight-llvm/references/agent-execution.md +0 -36
  592. package/skills/insight-managed-heap/references/agent-execution.md +0 -36
  593. package/skills/insight-managed-metadata/references/agent-execution.md +0 -36
  594. package/skills/insight-mitmproxy/references/agent-execution.md +0 -36
  595. package/skills/insight-overview/references/agent-execution.md +0 -36
  596. package/skills/insight-procmon/references/agent-execution.md +0 -36
  597. package/skills/insight-re/references/agent-execution.md +0 -36
  598. package/skills/insight-re/references/artifacts.md +0 -52
  599. package/skills/insight-re/references/persistent-client.mjs +0 -147
  600. package/skills/insight-re/references/persistent.md +0 -90
  601. package/skills/insight-re/references/recovery.md +0 -235
  602. package/skills/insight-re/references/storage.md +0 -139
  603. package/skills/insight-re/references/work-tracking.md +0 -261
  604. package/skills/insight-sevenzip/references/agent-execution.md +0 -36
  605. package/skills/insight-strace/references/agent-execution.md +0 -36
  606. package/skills/insight-tshark/references/agent-execution.md +0 -36
  607. package/skills/insight-windbg/references/agent-execution.md +0 -36
  608. /package/dist/src/{debugger-supervisor.d.ts → native/contract.js} +0 -0
  609. /package/runtime/native/{windows-job → windows}/NuGet.Config +0 -0
@@ -1,13 +1,12 @@
1
1
  import { CliError, Permission, ProfileStore, privateDirectory, command } from '@eyeauras/cli-factory';
2
2
  import { constants } from 'node:fs';
3
3
  import { access, lstat, mkdir, open, readdir, readlink, realpath, rename, rm, statfs, symlink, unlink } from 'node:fs/promises';
4
- import { createHash, randomUUID } from 'node:crypto';
4
+ import { randomUUID } from 'node:crypto';
5
5
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
6
6
  import { atomicWrite, readJson, toolProfileBusy } from './tool-runtime/store.js';
7
7
  import { listProcesses } from './tool-runtime/supervisor.js';
8
- import { runtimeProcesses } from './runtime-manager.js';
9
8
  import { digest } from './model.js';
10
- import { analysisTrees, inheritedStorage, legacyAnalysis, storageDefault, validateStorageDefault, checkStorageDefaultBase, writeStorageDefault } from './analysis-default.js';
9
+ import { analysisTrees, inheritedStorage, legacyAnalysis, storageDefault, validateStorageDefault, checkStorageDefaultBase, claimStorageBase, storageBaseMarker, writeStorageDefault } from './analysis-default.js';
11
10
  export { analysisTrees } from './analysis-default.js';
12
11
  // Move the complete runtime tree too: installation stages must share a filesystem with
13
12
  // installations, and both native checks and process runs can contain large generated DBs.
@@ -15,6 +14,7 @@ export { analysisTrees } from './analysis-default.js';
15
14
  const terminal = (state) => ['committed', 'rolled_back', 'cleaned'].includes(state);
16
15
  const inside = (parent, child) => { const r = relative(parent, child); return r === '' || !isAbsolute(r) && r !== '..' && !r.startsWith('..' + sep); };
17
16
  function fail(code, message) { throw new CliError(message, { code: 'storage.' + code }); }
17
+ const unmounted = () => fail('unavailable', 'Configured analysis storage is missing or changed; mount its volume. No fallback was created.');
18
18
  const missing = (e) => e.code === 'ENOENT';
19
19
  async function present(path) { try {
20
20
  return await lstat(path);
@@ -36,6 +36,7 @@ async function sync(path, directory = false) {
36
36
  await f.close();
37
37
  }
38
38
  }
39
+ const analysisMarker = '.insight-analysis.json';
39
40
  export function analysisDirectory(c) {
40
41
  const value = c.profile.values.analysisDirectory;
41
42
  if (value === null)
@@ -48,51 +49,25 @@ export function analysisDirectory(c) {
48
49
  fail('configuration', 'Invalid analysis directory in the Factory profile.');
49
50
  return value;
50
51
  }
51
- function stamp(st) { return [st.dev, st.ino, st.mode, st.size, st.mtimeNs, st.ctimeNs].join(':'); }
52
- async function hash(path, signal) {
53
- const f = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
54
- try {
55
- const st = await f.stat({ bigint: true });
56
- if (!st.isFile())
57
- fail('changed', 'Analysis file is no longer regular.');
58
- const h = createHash('sha256');
59
- for await (const chunk of f.createReadStream({ autoClose: false })) {
60
- signal?.throwIfAborted();
61
- h.update(chunk);
62
- }
63
- if (stamp(st) !== stamp(await f.stat({ bigint: true })))
64
- fail('changed', 'Analysis file changed while checking it.');
65
- return h.digest('hex');
66
- }
67
- finally {
68
- await f.close();
69
- }
70
- }
71
- async function inventory(root, trees, hashes, signal, validateLinks = true) {
52
+ async function inventory(root, trees, signal) {
72
53
  const entries = [];
73
54
  async function visit(path, depth) {
74
55
  signal?.throwIfAborted();
75
56
  if (depth > 128 || entries.length >= 1_000_000)
76
57
  fail('limit', 'Analysis inventory exceeds one million entries or 128 directory levels.');
77
- const at = join(root, path), st = await lstat(at, { bigint: true });
78
- if (st.size > BigInt(Number.MAX_SAFE_INTEGER))
79
- fail('limit', 'Analysis file exceeds the supported size counter.');
80
- const base = { path, size: st.isFile() ? Number(st.size) : 0, mode: Number(st.mode) & 0o777, stamp: stamp(st) };
58
+ const at = join(root, path), st = await lstat(at);
59
+ const base = { path, size: st.isFile() ? st.size : 0, mode: st.mode & 0o777 };
81
60
  if (st.isDirectory()) {
82
61
  entries.push({ ...base, kind: 'directory' });
83
62
  for (const name of (await readdir(at)).sort())
84
63
  await visit(path + '/' + name, depth + 1);
85
- if (stamp(st) !== stamp(await lstat(at, { bigint: true })))
86
- fail('changed', 'Analysis directory changed during inventory.');
87
64
  }
88
65
  else if (st.isFile())
89
- entries.push({ ...base, kind: 'file', ...(hashes ? { sha256: await hash(at, signal) } : {}) });
66
+ entries.push({ ...base, kind: 'file' });
90
67
  else if (st.isSymbolicLink()) {
91
- if (validateLinks) {
92
- const target = await realpath(at);
93
- if (!analysisTrees.some(tree => inside(join(root, tree), target)))
94
- fail('link', 'An analysis link escapes the migrated trees; retain and inspect it before migration.');
95
- }
68
+ const target = await realpath(at);
69
+ if (!analysisTrees.some(tree => inside(join(root, tree), target)))
70
+ fail('link', 'An analysis link escapes the migrated trees; retain and inspect it before migration.');
96
71
  entries.push({ ...base, kind: 'link', link: await readlink(at) });
97
72
  }
98
73
  else
@@ -103,7 +78,8 @@ async function inventory(root, trees, hashes, signal, validateLinks = true) {
103
78
  await visit(tree, 0);
104
79
  return entries;
105
80
  }
106
- function content(entries) { return entries.map(({ path, kind, size, sha256, link }) => ({ path, kind, size, ...(sha256 ? { sha256 } : {}), ...(link ? { link } : {}) })); }
81
+ /** Membership and sizes: what a copy or retained source must still hold. */
82
+ function content(entries) { return entries.map(({ path, kind, size, link }) => ({ path, kind, size, ...(link ? { link } : {}) })); }
107
83
  async function canonicalFuture(path) {
108
84
  const st = await present(path);
109
85
  if (st) {
@@ -117,46 +93,26 @@ async function canonicalFuture(path) {
117
93
  return join(await canonicalFuture(parent), basename(path));
118
94
  }
119
95
  async function existingParent(path) { return await present(path) ? path : existingParent(dirname(path)); }
120
- async function directoryIdentity(path) { const st = await lstat(path, { bigint: true }); if (!st.isDirectory() || await realpath(path) !== path)
121
- fail('volume', 'Migration volume or directory was replaced.'); return [st.dev, st.ino].join(':'); }
122
96
  /** Factory remains the only owner of profiles, settings, secrets and IPC admission. */
123
97
  export class AnalysisStorage {
124
98
  storeOverride;
125
99
  release;
126
100
  checkpoint;
127
- quiesce;
128
101
  active = new Map();
129
102
  changing = new Set();
130
- constructor(storeOverride, release, checkpoint,
131
- /** Stops idle owner services and idle warm workers (they hold no work) before the busy checks. */
132
- quiesce) {
103
+ constructor(storeOverride, release, checkpoint) {
133
104
  this.storeOverride = storeOverride;
134
105
  this.release = release;
135
106
  this.checkpoint = checkpoint;
136
- this.quiesce = quiesce;
137
107
  }
138
108
  control(c) { return join(c.appArguments.AppDataDirectory, 'storage'); }
139
109
  store(c) { return this.storeOverride ?? new ProfileStore({ applicationId: c.appArguments.AppName, appArguments: c.appArguments }); }
140
- async binding(c) { await mkdir(c.appArguments.AppDataDirectory, { recursive: true, mode: 0o700 }); return digest(await realpath(c.appArguments.AppDataDirectory)); }
141
110
  async journal(c, loadEntries = false) {
142
111
  const record = await readJson(join(this.control(c), 'migration.json'));
143
112
  if (!record)
144
113
  return;
145
- if (!/^[-a-f0-9]{36}$/.test(record.id))
146
- fail('journal', 'Invalid migration identity.');
147
- const j = { ...record, entries: loadEntries ? (await readJson(join(this.control(c), 'manifests', record.id + '.json'))) ?? [] : [] };
148
- if (j.schema !== 1 || j.profile !== c.profile.name || j.binding !== await this.binding(c) || !/^[-a-f0-9]{36}$/.test(j.id) ||
149
- !isAbsolute(j.source) || !isAbsolute(j.destination) || inside(j.source, j.destination) || inside(j.destination, j.source) ||
150
- !isAbsolute(j.destinationAnchor) || !inside(j.destinationAnchor, j.destination) || typeof j.sourceIdentity !== 'string' || typeof j.destinationIdentity !== 'string' ||
151
- !['copying', 'verified', 'activating', 'committed', 'rolling_back', 'rolled_back', 'cleaning', 'cleaned'].includes(j.state) ||
152
- ['automatic', 'makeDefault', 'defaultApplied', 'defaultSuperseded'].some(k => { const v = j[k]; return v !== undefined && typeof v !== 'boolean'; }) ||
153
- j.defaultPreviousRevision !== undefined && j.defaultPreviousRevision !== null && !/^[-a-f0-9]{36}$/.test(j.defaultPreviousRevision) ||
154
- j.automatic && (!j.defaultBinding || j.makeDefault || j.files !== 0 || j.bytes !== 0 || loadEntries && j.entries.length !== 0) ||
155
- !Array.isArray(j.trees) || j.trees.some(t => !analysisTrees.includes(t)) || !Array.isArray(j.entries) ||
156
- j.entries.some(e => !j.trees.some(t => e.path === t || e.path.startsWith(t + '/')) || e.path.split('/').some(p => p === '..' || p === '.' || p === '')) ||
157
- !/^[a-f0-9]{64}$/.test(j.manifest) || loadEntries && j.manifest !== digest(content(j.entries)))
158
- fail('journal', 'Migration journal failed its profile/path/integrity binding; preserve it.');
159
- return j;
114
+ // Our own journal, written by save(): parsed, not re-validated.
115
+ return { ...record, entries: loadEntries ? (await readJson(join(this.control(c), 'manifests', record.id + '.json'))) ?? [] : [] };
160
116
  }
161
117
  async save(c, j) {
162
118
  const manifest = join(this.control(c), 'manifests', j.id + '.json');
@@ -165,8 +121,11 @@ export class AnalysisStorage {
165
121
  const { entries, ...record } = j;
166
122
  await atomicWrite(join(this.control(c), 'migration.json'), record);
167
123
  }
168
- async validate(c, initializing = false) {
169
- const root = analysisDirectory(c), j = await this.journal(c);
124
+ /** Full availability, for storage commands; ordinary commands only refuse a pending migration (see prepare). */
125
+ async validate(c, initializing = false, j) {
126
+ const root = analysisDirectory(c);
127
+ if (j === undefined)
128
+ j = await this.journal(c);
170
129
  if (j && !terminal(j.state))
171
130
  fail('pending', 'Migration is incomplete. Use storage show, resume or rollback before research.');
172
131
  if (j && ['committed', 'cleaned'].includes(j.state) && root !== j.destination)
@@ -179,15 +138,25 @@ export class AnalysisStorage {
179
138
  validateStorageDefault(c, shared);
180
139
  return;
181
140
  }
182
- const marker = await readJson(join(root, '.insight-analysis.json'));
183
- if (!marker || marker.schema !== 1 || marker.binding !== await this.binding(c) || await realpath(root) !== root)
184
- fail('unavailable', 'Configured analysis storage is missing or changed; mount its volume. No fallback was created.');
185
- if (j && ['committed', 'cleaned'].includes(j.state) && j.targetIdentity && await directoryIdentity(root) !== j.targetIdentity)
186
- fail('binding', 'Committed analysis directory was replaced.');
187
- for (const tree of analysisTrees) {
188
- if (await realpath(join(c.appArguments.AppDataDirectory, tree)) !== join(root, tree))
189
- fail('binding', 'An analysis compatibility path was replaced; inspect storage show.');
141
+ if (!await present(join(root, analysisMarker)))
142
+ unmounted();
143
+ }
144
+ /** Volumes are recognized by presence and markers: a missing anchor or marker means the original volume is not mounted. */
145
+ async mounted(c, j, destination = true) {
146
+ const source = await present(j.source), configured = typeof j.previous === 'string' && j.previous !== c.appArguments.AppDataDirectory;
147
+ if (!source?.isDirectory() || configured && !await present(join(j.source, analysisMarker)))
148
+ fail('volume', 'The migration source is missing. Mount the original volume; no fallback was created.');
149
+ if (!destination)
150
+ return;
151
+ if (!(await present(j.destinationAnchor))?.isDirectory())
152
+ fail('volume', 'A migration volume disappeared. Mount the original volume before resuming; no fallback was created.');
153
+ if ((j.claimed || j.state !== 'copying') && !['rolling_back', 'rolled_back'].includes(j.state)) {
154
+ const marker = await readJson(join(j.destination, analysisMarker)).catch(() => undefined);
155
+ if (marker?.schema !== 1 || marker.id !== j.id)
156
+ fail('volume', 'The migration destination is missing its storage marker. Mount the original volume before resuming; no fallback was created.');
190
157
  }
158
+ if (j.defaultBaseMarker && storageBaseMarker(c, dirname(dirname(j.destination)))?.id !== j.defaultBaseMarker)
159
+ fail('volume', 'The selected storage base is missing its marker. Mount the original volume; no fallback was created.');
191
160
  }
192
161
  wrap(entry) {
193
162
  const run = entry.run;
@@ -200,7 +169,6 @@ export class AnalysisStorage {
200
169
  fail('busy', 'Storage migration is in progress.');
201
170
  this.active.set(key, (this.active.get(key) ?? 0) + 1);
202
171
  try {
203
- await this.validate(prepared);
204
172
  return await run(input, prepared);
205
173
  }
206
174
  finally {
@@ -212,19 +180,33 @@ export class AnalysisStorage {
212
180
  }
213
181
  } } : {}) };
214
182
  }
183
+ /**
184
+ * Per command: read the journal record once, refuse a pending migration and select the analysis root once. The
185
+ * storage marker is checked by storage commands (show, migrate, resume, rollback, cleanup), not by every command.
186
+ */
215
187
  async prepare(c) {
216
- const j = await this.journal(c), shared = inheritedStorage(c);
188
+ const j = await readJson(join(this.control(c), 'migration.json'));
217
189
  if (j?.automatic && !['cleaned', 'rolled_back'].includes(j.state)) {
190
+ validateStorageDefault(c, j.defaultBinding);
218
191
  await this.resume(c);
219
192
  c = { ...c, profile: await this.store(c).get(c.profile.name) };
220
193
  }
221
- else if (!j && shared) {
222
- validateStorageDefault(c, shared);
223
- await this.migrate(c, shared.base, false, true, true, shared);
224
- c = { ...c, profile: await this.store(c).get(c.profile.name) };
194
+ else if (j && !terminal(j.state))
195
+ fail('pending', 'Migration is incomplete. Use storage show, resume or rollback before research.');
196
+ let root = c.appArguments.AppDataDirectory;
197
+ if (c.profile.values.analysisDirectory !== undefined || j)
198
+ root = analysisDirectory(c);
199
+ else {
200
+ const shared = inheritedStorage(c);
201
+ if (shared) {
202
+ validateStorageDefault(c, shared);
203
+ await this.migrate(c, shared.base, false, true, true, shared);
204
+ c = { ...c, profile: await this.store(c).get(c.profile.name) };
205
+ root = analysisDirectory(c);
206
+ }
225
207
  }
226
208
  // One command keeps its selected root even if another profile changes the default.
227
- return { ...c, profile: { ...c.profile, values: { ...c.profile.values, analysisDirectory: analysisDirectory(c) } } };
209
+ return { ...c, profile: { ...c.profile, values: { ...c.profile.values, analysisDirectory: root } } };
228
210
  }
229
211
  async defaultBase(c, directory, existingOnly = false) {
230
212
  if (typeof directory !== 'string' || !isAbsolute(directory) || /[\0\r\n]/.test(directory))
@@ -253,22 +235,21 @@ export class AnalysisStorage {
253
235
  const key = c.appArguments.AppDataDirectory;
254
236
  if (this.changing.has(key) || this.active.get(key))
255
237
  fail('busy', 'Finish active commands before storage migration.');
256
- await this.quiesce?.(c);
257
238
  if (toolProfileBusy(key))
258
239
  fail('busy', 'Finish active commands before storage migration.');
259
240
  this.changing.add(key);
260
241
  try {
261
- let processes, native;
242
+ // release(c) ends the profile's contexts and native host; owned tool processes must have stopped.
243
+ await this.release(c);
244
+ let processes;
262
245
  try {
263
- processes = (await listProcesses(key)).filter(p => !['exited', 'failed'].includes(p.state));
264
- native = await runtimeProcesses(key);
246
+ processes = await listProcesses(key, { active: true });
265
247
  }
266
248
  catch (error) {
267
249
  throw new CliError('Cannot verify storage process inventory. Inspect storage show and preserve legacy compatibility paths before retrying.', { code: 'storage.inventory', cause: error, next: [['storage', 'show']] });
268
250
  }
269
- if (processes.length || native.length)
270
- throw new CliError('Close the profile contexts and stop its owned server/processes before migration. Unverified lifetimes also block copying.', { code: 'storage.busy', result: { processes, native }, next: [['tools', 'processes']] });
271
- await this.release(c);
251
+ if (processes.length)
252
+ throw new CliError('Stop the profile\'s owned tool processes before migration. Unverified lifetimes also block copying.', { code: 'storage.busy', result: { processes }, next: [['tools', 'processes']] });
272
253
  return await action();
273
254
  }
274
255
  finally {
@@ -292,21 +273,24 @@ export class AnalysisStorage {
292
273
  await access(parent, constants.R_OK | constants.W_OK | constants.X_OK);
293
274
  if (await present(source))
294
275
  await access(source, constants.R_OK | constants.W_OK | constants.X_OK);
295
- const entries = await inventory(source, analysisTrees, false, c.signal), bytes = entries.reduce((n, e) => n + e.size, 0);
276
+ const entries = await inventory(source, analysisTrees, c.signal), bytes = entries.reduce((n, e) => n + e.size, 0);
296
277
  if (!Number.isSafeInteger(bytes))
297
278
  fail('limit', 'Analysis inventory exceeds the supported size counter.');
298
279
  const fs = await statfs(parent, { bigint: true }), available = fs.bavail * fs.bsize, reserve = BigInt(entries.length) * 8192n + 16n * 1024n * 1024n;
299
280
  if (available < BigInt(bytes) + reserve)
300
281
  fail('capacity', 'Destination has insufficient free space for data and migration overhead.');
301
- return { source, destination, destinationAnchor: parent, destinationIdentity: await directoryIdentity(parent), bytes, entries: entries.length, availableBytes: available.toString(), requiredBytes: (BigInt(bytes) + reserve).toString(), trees: analysisTrees, sourceRetained: true, compatibilityPathsRetained: true };
282
+ return { inventory: entries, source, destination, destinationAnchor: parent, bytes, entries: entries.length, availableBytes: available.toString(), requiredBytes: (BigInt(bytes) + reserve).toString(), trees: analysisTrees, sourceRetained: true, compatibilityPathsRetained: true };
302
283
  }
303
- async show(c) {
284
+ async show(c, withUsage = false) {
304
285
  const j = await this.journal(c), root = analysisDirectory(c), shared = storageDefault(c);
305
286
  let usage, availability = 'available';
306
287
  try {
307
- await this.validate(c);
308
- const entries = await inventory(root, analysisTrees, false, c.signal);
309
- usage = { files: entries.filter(e => e.kind === 'file').length, bytes: entries.reduce((n, e) => n + e.size, 0) };
288
+ await this.validate(c, false, j ?? null);
289
+ // Usage walks every analysis file; it is computed only on request.
290
+ if (withUsage) {
291
+ const entries = await inventory(root, analysisTrees, c.signal);
292
+ usage = { files: entries.filter(e => e.kind === 'file').length, bytes: entries.reduce((n, e) => n + e.size, 0) };
293
+ }
310
294
  }
311
295
  catch (error) {
312
296
  availability = error instanceof CliError ? error.code : (error.code ?? 'unavailable');
@@ -317,27 +301,17 @@ export class AnalysisStorage {
317
301
  }
318
302
  async migrate(c, directory, dryRun = false, emptyOnly = false, profileOnly = false, automatic) {
319
303
  return this.exclusive(c, async () => {
304
+ // An automatic initialization's default was validated by prepare.
320
305
  await this.validate(c, true);
321
- if (automatic)
322
- validateStorageDefault(c, automatic);
323
- const plan = await this.preflight(c, directory);
324
- if (automatic) {
325
- validateStorageDefault(c, automatic);
326
- if (plan.destination !== join(automatic.base, c.appArguments.AppName, c.profile.name))
327
- fail('binding', 'Automatic initialization changed its destination.');
328
- }
306
+ const { inventory: entries, ...plan } = await this.preflight(c, directory);
329
307
  if (!profileOnly)
330
308
  await this.defaultBase(c, directory);
331
309
  if (dryRun)
332
310
  return { state: 'preflight', setsInstallationDefault: !profileOnly, ...plan };
333
311
  if (emptyOnly && plan.entries)
334
312
  fail('data', 'This profile already has analysis data. Use storage migrate --directory to preserve it.');
335
- const entries = await inventory(plan.source, analysisTrees, true, c.signal), id = randomUUID();
336
- if (emptyOnly && entries.length)
337
- fail('data', 'Analysis appeared during empty-profile initialization; no migration was started.');
338
- const binding = await this.binding(c);
339
- const j = { schema: 1, id, profile: c.profile.name, binding, source: plan.source, destination: plan.destination,
340
- sourceIdentity: await directoryIdentity(plan.source), destinationAnchor: plan.destinationAnchor, destinationIdentity: plan.destinationIdentity,
313
+ const id = randomUUID();
314
+ const j = { schema: 1, id, profile: c.profile.name, source: plan.source, destination: plan.destination, destinationAnchor: plan.destinationAnchor,
341
315
  previous: typeof c.profile.values.analysisDirectory === 'string' ? c.profile.values.analysisDirectory : null, automatic: Boolean(automatic), defaultBinding: automatic, makeDefault: !profileOnly, defaultPreviousRevision: storageDefault(c)?.revision ?? null, state: 'copying', entries, trees: [...analysisTrees], manifest: digest(content(entries)), createdAt: new Date().toISOString(), bytes: entries.reduce((n, e) => n + e.size, 0), files: entries.filter(e => e.kind === 'file').length };
342
316
  // Reserve durably before any destination or source changes. All ordinary commands now freeze.
343
317
  await this.save(c, j);
@@ -345,31 +319,14 @@ export class AnalysisStorage {
345
319
  return this.continue(c, j);
346
320
  });
347
321
  }
348
- async checkCopy(c, j) {
349
- if (await canonicalFuture(j.destination) !== j.destination || j.targetIdentity && await directoryIdentity(j.destination) !== j.targetIdentity)
350
- fail('binding', 'Destination directory was replaced.');
351
- const actual = await inventory(j.destination, j.trees, true, c.signal, false);
352
- // Empty managed roots also exist to receive future writes; normalize them out of the manifest.
353
- const expected = content(j.entries), actualContent = content(actual).filter(e => !j.trees.includes(e.path) || expected.some(x => x.path === e.path));
354
- if (digest(actualContent) !== j.manifest)
355
- fail('verification', 'Copied analysis bytes or directory membership differ; source remains retained.');
356
- }
357
322
  async continue(c, j) {
358
- if (await directoryIdentity(j.source) !== j.sourceIdentity || await directoryIdentity(j.destinationAnchor) !== j.destinationIdentity)
359
- fail('volume', 'A migration volume changed or disappeared. Mount the original volume before resuming; no fallback was created.');
360
- if (await canonicalFuture(j.destination) !== j.destination || j.targetIdentity && await directoryIdentity(j.destination) !== j.targetIdentity)
361
- fail('binding', 'Destination directory was replaced; no migration write was made.');
362
- if (j.defaultBinding)
363
- validateStorageDefault(c, j.defaultBinding);
364
- if (j.defaultBaseIdentity && await directoryIdentity(dirname(dirname(j.destination))) !== j.defaultBaseIdentity)
365
- fail('volume', 'The selected storage base directory was replaced.');
323
+ await this.mounted(c, j);
366
324
  if (j.state === 'rolling_back')
367
325
  return this.restore(c, j);
368
326
  if (j.state === 'cleaning')
369
327
  return this.finishCleanup(c, j);
370
328
  if (terminal(j.state) && !(j.automatic && j.state === 'committed')) {
371
329
  const selected = { ...c, profile: await this.store(c).get(c.profile.name) };
372
- await this.validate(selected);
373
330
  const status = await this.show(selected);
374
331
  if (status.availability !== 'available')
375
332
  throw new CliError('Completed migration storage is unavailable. Inspect storage show before retrying.', { code: 'storage.unavailable', next: [['storage', 'show']] });
@@ -377,13 +334,9 @@ export class AnalysisStorage {
377
334
  }
378
335
  if (j.makeDefault && !j.defaultApplied) {
379
336
  const base = dirname(dirname(j.destination));
380
- if (await canonicalFuture(base) !== base)
381
- fail('binding', 'Storage default base was replaced.');
382
337
  await mkdir(base, { recursive: true, mode: 0o700 });
383
- if (await directoryIdentity(j.destinationAnchor) !== j.destinationIdentity)
384
- fail('volume', 'The default storage volume changed.');
385
- if (!j.defaultBaseIdentity) {
386
- j.defaultBaseIdentity = await directoryIdentity(base);
338
+ if (!j.defaultBaseMarker) {
339
+ j.defaultBaseMarker = (await claimStorageBase(c, base)).id;
387
340
  await this.save(c, j);
388
341
  }
389
342
  const result = await writeStorageDefault(c, base, j.id, j.defaultPreviousRevision ?? null);
@@ -396,17 +349,14 @@ export class AnalysisStorage {
396
349
  }
397
350
  if (j.state === 'copying') {
398
351
  await privateDirectory(j.destination);
399
- if (!j.targetIdentity) {
400
- if ((await readdir(j.destination)).length)
401
- fail('destination', 'Unreserved destination contents appeared before copying.');
402
- j.targetIdentity = await directoryIdentity(j.destination);
403
- await this.save(c, j);
404
- }
352
+ const marker = join(j.destination, analysisMarker), old = await readJson(marker);
353
+ if (old && old.id !== j.id)
354
+ fail('destination', 'Destination is claimed by another migration.');
355
+ if (!old && (await readdir(j.destination)).length)
356
+ fail('destination', 'Unreserved destination contents appeared before copying.');
405
357
  let remaining = 0n;
406
358
  for (const e of j.entries)
407
359
  if (e.kind === 'file' && !await present(join(j.destination, e.path))) {
408
- if (await canonicalFuture(dirname(join(j.destination, e.path))) !== dirname(join(j.destination, e.path)))
409
- fail('binding', 'A destination parent was replaced.');
410
360
  // Reclaim only this transaction's unacknowledged file before checking capacity.
411
361
  await unlink(join(j.destination, e.path) + '.insight-copy-' + j.id).catch(e => { if (!missing(e))
412
362
  throw e; });
@@ -415,75 +365,46 @@ export class AnalysisStorage {
415
365
  const fs = await statfs(j.destinationAnchor, { bigint: true });
416
366
  if (fs.bavail * fs.bsize < remaining + BigInt(j.entries.length) * 8192n + 16n * 1024n * 1024n)
417
367
  fail('capacity', 'Destination no longer has sufficient free space; source and journal remain retained.');
418
- const marker = join(j.destination, '.insight-analysis.json'), old = await readJson(marker);
419
- if (old && (old.id !== j.id || old.binding !== j.binding))
420
- fail('destination', 'Destination is claimed by another migration.');
421
- await atomicWrite(marker, { schema: 1, id: j.id, binding: j.binding, profile: j.profile });
422
- for (const tree of j.trees) {
423
- const path = join(j.destination, tree);
424
- if (await canonicalFuture(path) !== path)
425
- fail('binding', 'A destination tree was replaced.');
426
- await mkdir(path, { recursive: true, mode: 0o700 });
368
+ await atomicWrite(marker, { schema: 1, id: j.id, profile: j.profile });
369
+ if (!j.claimed) {
370
+ j.claimed = true;
371
+ await this.save(c, j);
427
372
  }
373
+ for (const tree of j.trees)
374
+ await mkdir(join(j.destination, tree), { recursive: true, mode: 0o700 });
428
375
  let completed = 0;
429
376
  for (const entry of j.entries) {
430
377
  c.signal.throwIfAborted();
431
378
  const at = join(j.destination, entry.path), source = join(j.source, entry.path);
432
- if (await canonicalFuture(entry.kind === 'directory' ? at : dirname(at)) !== (entry.kind === 'directory' ? at : dirname(at)))
433
- fail('binding', 'A destination directory was replaced.');
434
379
  if (entry.kind === 'directory')
435
380
  await mkdir(at, { recursive: true, mode: 0o700 });
436
381
  else if (entry.kind === 'link') {
437
- const st = await present(at);
438
- if (st) {
439
- if (!st.isSymbolicLink() || await readlink(at) !== entry.link)
440
- fail('destination', 'A destination link changed.');
441
- }
442
- else
382
+ if (!await present(at))
443
383
  await symlink(entry.link, at);
444
384
  }
445
- else {
446
- const st = await present(at);
447
- if (st) {
448
- if (!st.isFile() || st.size !== entry.size || await hash(at, c.signal) !== entry.sha256)
449
- fail('verification', 'A completed destination file changed; preserve and inspect it.');
450
- }
451
- else {
452
- const partial = at + '.insight-copy-' + j.id;
453
- await rm(partial, { force: true });
454
- const input = await open(source, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK), output = await open(partial, 'wx', 0o600);
455
- try {
456
- if (stamp(await input.stat({ bigint: true })) !== entry.stamp)
457
- fail('changed', 'Source changed since migration reservation. Roll back before retrying.');
458
- const h = createHash('sha256');
459
- let size = 0;
460
- for await (const chunk of input.createReadStream({ autoClose: false })) {
461
- c.signal.throwIfAborted();
462
- size += chunk.length;
463
- h.update(chunk);
464
- await output.writeFile(chunk);
465
- }
466
- if (size !== entry.size || h.digest('hex') !== entry.sha256 || stamp(await input.stat({ bigint: true })) !== entry.stamp)
467
- fail('changed', 'Source changed during copy.');
468
- await output.chmod((entry.mode & 0o700) | 0o400);
469
- await output.sync();
470
- }
471
- finally {
472
- await input.close();
473
- await output.close();
385
+ else if (!await present(at)) {
386
+ const partial = at + '.insight-copy-' + j.id;
387
+ await rm(partial, { force: true });
388
+ const input = await open(source, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK), output = await open(partial, 'wx', 0o600);
389
+ try {
390
+ for await (const chunk of input.createReadStream({ autoClose: false })) {
391
+ c.signal.throwIfAborted();
392
+ await output.writeFile(chunk);
474
393
  }
475
- await rename(partial, at);
476
- await sync(dirname(at), true);
394
+ await output.chmod((entry.mode & 0o700) | 0o400);
395
+ await output.sync();
477
396
  }
397
+ finally {
398
+ await input.close();
399
+ await output.close();
400
+ }
401
+ await rename(partial, at);
402
+ await sync(dirname(at), true);
478
403
  }
479
404
  await this.checkpoint?.('copied');
480
405
  if (++completed % 32 === 0)
481
406
  await atomicWrite(join(this.control(c), 'progress.json'), { completed, total: j.entries.length, phase: 'copying' });
482
407
  }
483
- const source = await inventory(j.source, j.trees, true, c.signal);
484
- if (digest(source) !== digest(j.entries))
485
- fail('changed', 'Source changed while copying; switching was refused.');
486
- await this.checkCopy(c, j);
487
408
  for (const e of [...j.entries].reverse())
488
409
  if (e.kind === 'directory')
489
410
  await sync(join(j.destination, e.path), true);
@@ -492,36 +413,17 @@ export class AnalysisStorage {
492
413
  await this.save(c, j);
493
414
  }
494
415
  if (j.state === 'verified') {
495
- const source = await inventory(j.source, j.trees, true, c.signal);
496
- if (digest(source) !== digest(j.entries))
497
- fail('changed', 'Source changed before activation.');
498
- await this.checkCopy(c, j);
499
416
  j.state = 'activating';
500
417
  await this.save(c, j);
501
418
  }
502
419
  if (j.state === 'activating') {
503
- await this.checkCopy(c, j);
504
- const backupRoot = join(j.source, '.storage-retained', j.id), backupParent = dirname(backupRoot);
505
- if (!j.backupIdentity) {
506
- if (await canonicalFuture(backupRoot) !== backupRoot)
507
- fail('binding', 'Retained source ancestry was replaced.');
508
- await mkdir(backupRoot, { recursive: true, mode: 0o700 });
509
- if ((await readdir(backupRoot)).length)
510
- fail('binding', 'Unreserved retained source contents appeared.');
511
- j.backupIdentity = await directoryIdentity(backupRoot);
512
- j.backupParentIdentity = await directoryIdentity(backupParent);
513
- await this.save(c, j);
514
- }
515
- await this.checkBackup(j);
420
+ await mkdir(join(j.source, '.storage-retained', j.id), { recursive: true, mode: 0o700 });
516
421
  // After this durable intent, cancellation leaves a recoverable alias transaction.
517
422
  for (const tree of j.trees) {
518
423
  const source = join(j.source, tree), backup = join(j.source, '.storage-retained', j.id, tree), target = join(j.destination, tree);
519
424
  const st = await present(source);
520
- if (st?.isSymbolicLink()) {
521
- if (await realpath(source) !== target)
522
- fail('binding', 'An activating source alias changed.');
425
+ if (st?.isSymbolicLink())
523
426
  continue;
524
- }
525
427
  if (st) {
526
428
  await mkdir(dirname(backup), { recursive: true, mode: 0o700 });
527
429
  if (await present(backup))
@@ -535,7 +437,6 @@ export class AnalysisStorage {
535
437
  await symlink(target, source, process.platform === 'win32' ? 'junction' : 'dir');
536
438
  await sync(dirname(source), true);
537
439
  }
538
- await this.checkCopy(c, j);
539
440
  await this.checkpoint?.('aliases-installed');
540
441
  await this.store(c).set(c.profile.name, { analysisDirectory: j.destination });
541
442
  await sync(join(c.appArguments.RoamingAppDataDirectory, 'profiles.json'));
@@ -557,21 +458,16 @@ export class AnalysisStorage {
557
458
  async repairBinding(c, j) {
558
459
  if (!['committed', 'cleaned'].includes(j.state))
559
460
  fail('repair', 'Profile repair requires a completed migration. Resume the pending transaction without --repair-profile.');
560
- if (await directoryIdentity(j.source) !== j.sourceIdentity || await canonicalFuture(j.destination) !== j.destination || !j.targetIdentity || await directoryIdentity(j.destination) !== j.targetIdentity)
561
- fail('binding', 'Migration source or destination identity changed. Preserve both copies; profile repair was refused.');
562
- if (await directoryIdentity(j.destinationAnchor) !== j.destinationIdentity)
563
- fail('volume', 'Migration destination volume changed. Profile repair was refused.');
461
+ const marker = await readJson(join(j.destination, analysisMarker)).catch(() => undefined);
462
+ if (marker?.schema !== 1 || marker.id !== j.id || marker.profile !== j.profile)
463
+ fail('binding', 'Destination ownership does not match the retained migration. Profile repair was refused.');
464
+ await this.mounted(c, j);
564
465
  if (j.defaultBinding)
565
466
  validateStorageDefault(c, j.defaultBinding);
566
- if (j.defaultBaseIdentity && await directoryIdentity(dirname(dirname(j.destination))) !== j.defaultBaseIdentity)
567
- fail('volume', 'Storage base changed. Profile repair was refused.');
568
- const marker = await readJson(join(j.destination, '.insight-analysis.json'));
569
- if (marker?.schema !== 1 || marker.id !== j.id || marker.binding !== j.binding || marker.profile !== j.profile)
570
- fail('binding', 'Destination ownership does not match the retained migration. Profile repair was refused.');
571
467
  for (const tree of analysisTrees) {
572
468
  const target = join(j.destination, tree), alias = join(j.source, tree);
573
469
  try {
574
- if (await canonicalFuture(target) !== target || !(await lstat(target)).isDirectory() || !(await lstat(alias)).isSymbolicLink() || await realpath(alias) !== target)
470
+ if (!(await lstat(target)).isDirectory() || !(await lstat(alias)).isSymbolicLink())
575
471
  fail('aliases', 'A migration compatibility path changed. Preserve the conflicting path and restore its recorded destination before profile repair.');
576
472
  }
577
473
  catch (error) {
@@ -617,8 +513,6 @@ export class AnalysisStorage {
617
513
  fail('retention', 'Retained source cleanup has begun. Resume cleanup; rollback can no longer restore a complete source.');
618
514
  if (j.state === 'rolled_back')
619
515
  return { state: j.state, id: j.id };
620
- if (j.state === 'committed' || j.state === 'activating')
621
- await this.checkCopy(c, j);
622
516
  if (j.state === 'copying' || j.state === 'verified')
623
517
  j.rollbackUnactivated = true;
624
518
  else
@@ -629,17 +523,13 @@ export class AnalysisStorage {
629
523
  });
630
524
  }
631
525
  async restore(c, j) {
632
- if (j.rollbackUnactivated) {
633
- if (await directoryIdentity(j.source) !== j.sourceIdentity)
634
- fail('volume', 'Original source volume changed; rollback refused.');
635
- }
526
+ if (j.rollbackUnactivated)
527
+ await this.mounted(c, j, false);
636
528
  else
637
529
  await this.checkRetained(c, j);
638
530
  for (const tree of j.rollbackUnactivated ? [] : j.trees) {
639
531
  const source = join(j.source, tree), backup = join(j.source, '.storage-retained', j.id, tree), st = await present(source);
640
532
  if (st?.isSymbolicLink()) {
641
- if (await realpath(source) !== join(j.destination, tree))
642
- fail('binding', 'Rollback source alias changed.');
643
533
  await unlink(source);
644
534
  await sync(dirname(source), true);
645
535
  }
@@ -665,10 +555,7 @@ export class AnalysisStorage {
665
555
  fail('retention', 'Cleanup requires a committed migration.');
666
556
  if (j.state === 'cleaned')
667
557
  return { state: j.state, id: j.id };
668
- await this.validate(c);
669
- const root = join(j.source, '.storage-retained', j.id), retained = await inventory(root, j.trees, true, c.signal, false);
670
- if (digest(content(retained)) !== j.manifest)
671
- fail('changed', 'Retained source changed; cleanup refused. Preserve it for inspection.');
558
+ await this.validate(c, false, j);
672
559
  j.state = 'cleaning';
673
560
  await this.save(c, j);
674
561
  await this.checkpoint?.('cleanup-reserved');
@@ -676,7 +563,6 @@ export class AnalysisStorage {
676
563
  });
677
564
  }
678
565
  async finishCleanup(c, j) {
679
- await this.checkBackup(j, true);
680
566
  const root = join(j.source, '.storage-retained', j.id);
681
567
  await rm(root, { recursive: true, force: true });
682
568
  if (await present(dirname(root)))
@@ -685,39 +571,22 @@ export class AnalysisStorage {
685
571
  await this.save(c, j);
686
572
  return { state: j.state, id: j.id, compatibilityPathsRetained: true };
687
573
  }
574
+ /** Every migrated tree is still present in the retained source (or not yet moved aside). */
688
575
  async checkRetained(c, j) {
689
- if (await directoryIdentity(j.source) !== j.sourceIdentity)
690
- fail('volume', 'Original source volume changed; rollback refused.');
691
- if (j.backupIdentity)
692
- await this.checkBackup(j);
693
- const entries = [];
576
+ await this.mounted(c, j, false);
694
577
  for (const tree of j.trees) {
695
- const backupRoot = join(j.source, '.storage-retained', j.id), backup = join(backupRoot, tree);
696
- if (await present(backup))
697
- entries.push(...await inventory(backupRoot, [tree], true, c.signal, false));
698
- else {
699
- const st = await present(join(j.source, tree));
700
- if (st && !st.isSymbolicLink())
701
- entries.push(...await inventory(j.source, [tree], true, c.signal, false));
702
- }
578
+ if (!j.entries.some(e => e.path === tree))
579
+ continue;
580
+ const source = await present(join(j.source, tree));
581
+ if (!await present(join(j.source, '.storage-retained', j.id, tree)) && !(source && !source.isSymbolicLink()))
582
+ fail('verification', 'Retained source is missing; rollback refused. The destination remains retained.');
703
583
  }
704
- if (digest(content(entries)) !== j.manifest)
705
- fail('verification', 'Retained source bytes changed; rollback refused. The destination remains retained.');
706
- }
707
- async checkBackup(j, allowAbsent = false) {
708
- const root = join(j.source, '.storage-retained', j.id), parent = dirname(root);
709
- if (!j.backupIdentity || !j.backupParentIdentity || await directoryIdentity(parent) !== j.backupParentIdentity || await canonicalFuture(root) !== root)
710
- fail('binding', 'Retained source ancestry was replaced; no deletion or restore was attempted.');
711
- if (!await present(root) && allowAbsent)
712
- return;
713
- if (await directoryIdentity(root) !== j.backupIdentity)
714
- fail('binding', 'Retained source directory was replaced; no deletion or restore was attempted.');
715
584
  }
716
585
  commands() {
717
586
  const profileOnly = { flags: '--profile-only', description: 'Keep the installation default unchanged; move only this profile' };
718
587
  const directory = { flags: '--directory <path>', description: 'Absolute base directory; app name and profile are appended', required: true };
719
588
  return command('storage', 'Inspect and migrate profile analysis data', [
720
- command('show', 'Show effective analysis storage, usage and retained migration', (_i, c) => this.show(c), { permission: Permission.ReadOnly }),
589
+ command('show', 'Show effective analysis storage and retained migration; --usage also counts analysis files and bytes', ({ options: o }, c) => this.show(c, Boolean(o.usage)), { permission: Permission.ReadOnly, options: [{ flags: '--usage', description: 'Walk the analysis trees to report file count and bytes' }] }),
721
590
  command('default', 'Set the installation storage base for new profiles; preserve existing data locations', ({ options: o }, c) => this.setDefault(c, o.directory), { permission: Permission.Update, options: [directory] }),
722
591
  command('configure', 'Choose storage for an empty profile and subsequent new profiles', ({ options: o }, c) => this.migrate(c, o.directory, false, true, Boolean(o.profileOnly)), { permission: Permission.Update, options: [directory, profileOnly] }),
723
592
  command('migrate', 'Copy and verify all analysis data, retain source, then switch storage', ({ options: o }, c) => this.migrate(c, o.directory, Boolean(o.dryRun), false, Boolean(o.profileOnly)), { permission: Permission.Update, options: [directory, profileOnly, { flags: '--dry-run', description: 'Read-only path, capacity and quiescence preflight; create no migration' }] }),