@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.
- package/.cli-package-build.json +1 -1
- package/README.md +16 -23
- package/SKILL.md +6 -44
- package/dist/src/activity-audit.d.ts +33 -46
- package/dist/src/activity-audit.js +120 -195
- package/dist/src/analysis-default.d.ts +10 -2
- package/dist/src/analysis-default.js +62 -47
- package/dist/src/analysis-storage.d.ts +13 -13
- package/dist/src/analysis-storage.js +127 -258
- package/dist/src/artifacts.d.ts +5 -1
- package/dist/src/artifacts.js +31 -46
- package/dist/src/audit-commands.d.ts +6 -1
- package/dist/src/audit-commands.js +9 -2
- package/dist/src/audit-retention.d.ts +5 -23
- package/dist/src/audit-retention.js +37 -150
- package/dist/src/binary.js +4 -13
- package/dist/src/budgets.d.ts +2 -2
- package/dist/src/budgets.js +7 -9
- package/dist/src/capture.js +17 -30
- package/dist/src/cli.d.ts +9 -4
- package/dist/src/cli.js +288 -473
- package/dist/src/code-references.d.ts +2 -13
- package/dist/src/code-references.js +7 -99
- package/dist/src/context-diagnostics.d.ts +1 -23
- package/dist/src/context-diagnostics.js +1 -83
- package/dist/src/core/coordinator.d.ts +298 -0
- package/dist/src/core/coordinator.js +591 -0
- package/dist/src/core/layout.d.ts +51 -0
- package/dist/src/core/layout.js +55 -0
- package/dist/src/core/legacy-import.d.ts +55 -0
- package/dist/src/core/legacy-import.js +193 -0
- package/dist/src/cross-results.d.ts +3 -3
- package/dist/src/cross-results.js +4 -42
- package/dist/src/cross.js +2 -3
- package/dist/src/debugger-results.d.ts +1 -6
- package/dist/src/debugger-results.js +21 -153
- package/dist/src/debugger.d.ts +21 -11
- package/dist/src/debugger.js +106 -168
- package/dist/src/decode-results.d.ts +2 -1
- package/dist/src/decode-results.js +4 -20
- package/dist/src/diagnostic-error.d.ts +1 -1
- package/dist/src/diagnostic-error.js +4 -23
- package/dist/src/die.js +1 -23
- package/dist/src/dnspy-runtime.js +5 -12
- package/dist/src/dnspy.js +13 -28
- package/dist/src/dotnet-diagnostics.js +1 -1
- package/dist/src/extensions.d.ts +2 -3
- package/dist/src/extensions.js +14 -91
- package/dist/src/frida-worker.js +0 -20
- package/dist/src/frida.js +3 -26
- package/dist/src/function-boundaries.d.ts +2 -2
- package/dist/src/function-boundaries.js +9 -61
- package/dist/src/function-entries.d.ts +2 -2
- package/dist/src/function-entries.js +6 -36
- package/dist/src/function-inspection.d.ts +2 -2
- package/dist/src/function-inspection.js +17 -33
- package/dist/src/function-results.d.ts +1 -3
- package/dist/src/function-results.js +2 -13
- package/dist/src/hub/admin.d.ts +101 -0
- package/dist/src/hub/admin.js +314 -0
- package/dist/src/hub/autostart.d.ts +111 -0
- package/dist/src/hub/autostart.js +207 -0
- package/dist/src/hub/bundle.d.ts +33 -0
- package/dist/src/hub/bundle.js +25 -0
- package/dist/src/hub/client.d.ts +90 -0
- package/dist/src/hub/client.js +256 -0
- package/dist/src/hub/commands.d.ts +13 -0
- package/dist/src/hub/commands.js +280 -0
- package/dist/src/hub/contract.d.ts +87 -0
- package/dist/src/hub/contract.js +3 -0
- package/dist/src/hub/extensions.d.ts +41 -0
- package/dist/src/hub/extensions.js +3 -0
- package/dist/src/hub/ghidra.d.ts +70 -0
- package/dist/src/hub/ghidra.js +197 -0
- package/dist/src/hub/index.d.ts +6 -0
- package/dist/src/hub/index.js +7 -0
- package/dist/src/{work/store.d.ts → hub/ledger-store.d.ts} +57 -94
- package/dist/src/hub/ledger-store.js +919 -0
- package/dist/src/hub/ledger.d.ts +4 -0
- package/dist/src/hub/ledger.js +173 -0
- package/dist/src/hub/lock.d.ts +7 -0
- package/dist/src/hub/lock.js +53 -0
- package/dist/src/hub/repository.d.ts +45 -0
- package/dist/src/hub/repository.js +130 -0
- package/dist/src/hub/server.d.ts +86 -0
- package/dist/src/hub/server.js +414 -0
- package/dist/src/hub/settings.d.ts +36 -0
- package/dist/src/hub/settings.js +112 -0
- package/dist/src/hub/storage.d.ts +13 -0
- package/dist/src/hub/storage.js +46 -0
- package/dist/src/hub/store.d.ts +75 -0
- package/dist/src/hub/store.js +188 -0
- package/dist/src/ilspy.js +1 -1
- package/dist/src/internal-timing.d.ts +2 -9
- package/dist/src/internal-timing.js +2 -95
- package/dist/src/lldb.js +3 -15
- package/dist/src/llvm.js +0 -9
- package/dist/src/managed-heap.js +3 -7
- package/dist/src/managed-metadata.js +2 -5
- package/dist/src/memory-inputs.d.ts +1 -4
- package/dist/src/memory-inputs.js +10 -40
- package/dist/src/mitmproxy.d.ts +35 -4
- package/dist/src/mitmproxy.js +59 -40
- package/dist/src/model.d.ts +0 -73
- package/dist/src/model.js +0 -45
- package/dist/src/mutations.d.ts +1 -1
- package/dist/src/mutations.js +5 -10
- package/dist/src/native/contract.d.ts +130 -0
- package/dist/src/native/ghidra.d.ts +58 -0
- package/dist/src/native/ghidra.js +77 -0
- package/dist/src/native/host.d.ts +71 -0
- package/dist/src/native/host.js +265 -0
- package/dist/src/native/index.d.ts +13 -0
- package/dist/src/native/index.js +19 -0
- package/dist/src/native/jvm.d.ts +54 -0
- package/dist/src/native/jvm.js +47 -0
- package/dist/src/native/worker.d.ts +70 -0
- package/dist/src/native/worker.js +240 -0
- package/dist/src/native-inputs.d.ts +9 -14
- package/dist/src/native-inputs.js +22 -110
- package/dist/src/native-merge-patches.d.ts +2 -2
- package/dist/src/native-merge-patches.js +14 -14
- package/dist/src/persistent-client.js +53 -25
- package/dist/src/procmon.js +17 -31
- package/dist/src/program-files.d.ts +42 -0
- package/dist/src/program-files.js +148 -0
- package/dist/src/queries.js +2 -15
- package/dist/src/query-policy.d.ts +0 -2
- package/dist/src/query-policy.js +1 -14
- package/dist/src/research.d.ts +59 -238
- package/dist/src/research.js +212 -906
- package/dist/src/runtime-identity.d.ts +8 -0
- package/dist/src/runtime-identity.js +26 -0
- package/dist/src/runtime-manager.d.ts +1 -11
- package/dist/src/runtime-manager.js +10 -145
- package/dist/src/runtime-selection.d.ts +1 -1
- package/dist/src/runtime-selection.js +5 -37
- package/dist/src/saved-materials.js +8 -51
- package/dist/src/scripts.d.ts +1 -1
- package/dist/src/scripts.js +15 -15
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk.js +8 -8
- package/dist/src/sevenzip.js +1 -3
- package/dist/src/strace.js +0 -3
- package/dist/src/string-anchors.d.ts +2 -3
- package/dist/src/string-anchors.js +8 -101
- package/dist/src/text-window.d.ts +5 -4
- package/dist/src/text-window.js +4 -4
- package/dist/src/tool-runtime/archives.d.ts +1 -1
- package/dist/src/tool-runtime/archives.js +11 -20
- package/dist/src/tool-runtime/catalog.js +2 -5
- package/dist/src/tool-runtime/commands.js +1 -3
- package/dist/src/tool-runtime/deadline.js +2 -7
- package/dist/src/tool-runtime/definition.js +1 -31
- package/dist/src/tool-runtime/identity.js +6 -87
- package/dist/src/tool-runtime/installer.d.ts +2 -6
- package/dist/src/tool-runtime/installer.js +14 -76
- package/dist/src/tool-runtime/java-arguments.js +4 -10
- package/dist/src/tool-runtime/launch-worker.js +2 -8
- package/dist/src/tool-runtime/run.d.ts +2 -0
- package/dist/src/tool-runtime/run.js +20 -8
- package/dist/src/tool-runtime/store.d.ts +3 -3
- package/dist/src/tool-runtime/store.js +21 -83
- package/dist/src/tool-runtime/supervisor.d.ts +6 -11
- package/dist/src/tool-runtime/supervisor.js +155 -214
- package/dist/src/tool-runtime/windows-helper.d.ts +5 -0
- package/dist/src/tool-runtime/windows-helper.js +13 -0
- package/dist/src/tool-runtime/windows-job.d.ts +5 -5
- package/dist/src/tool-runtime/windows-job.js +13 -31
- package/dist/src/tshark.js +14 -27
- package/dist/src/ui-results.d.ts +3 -2
- package/dist/src/ui-results.js +16 -53
- package/dist/src/ui.d.ts +12 -13
- package/dist/src/ui.js +32 -70
- package/dist/src/version-tracking.d.ts +25 -39
- package/dist/src/version-tracking.js +70 -174
- package/dist/src/windbg.d.ts +1 -1
- package/dist/src/windbg.js +2 -8
- package/dist/src/work/client.d.ts +63 -0
- package/dist/src/work/client.js +163 -0
- package/dist/src/work/commands.d.ts +3 -1
- package/dist/src/work/commands.js +158 -184
- package/dist/src/work/dashboard.d.ts +2 -2
- package/dist/src/work/dashboard.js +7 -8
- package/dist/src/work/legacy.d.ts +8 -0
- package/dist/src/work/legacy.js +70 -0
- package/dist/src/work/model.d.ts +0 -3
- package/dist/src/work/model.js +0 -10
- package/dist/src/work/timing.d.ts +3 -3
- package/dist/src/work/timing.js +21 -25
- package/dist/src/workspace.d.ts +4 -250
- package/dist/src/workspace.js +11 -699
- package/node_modules/@eyeauras/cli-factory/README.md +6 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/cli.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/cli.js +76 -28
- package/node_modules/@eyeauras/cli-factory/dist/src/cli.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/command.js +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/command.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.js +18 -6
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts +44 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/{profile-file.js → file-publication.js} +41 -113
- package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts +5 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.js +17 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts +9 -4
- package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/index.js +5 -2
- package/node_modules/@eyeauras/cli-factory/dist/src/index.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js +11 -18
- package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts +10 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js +69 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts +3 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/output.js +74 -14
- package/node_modules/@eyeauras/cli-factory/dist/src/output.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts +3 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js +9 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/permissions.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js +3 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts +16 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js +83 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts +5 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts +49 -7
- package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/view.js +83 -6
- package/node_modules/@eyeauras/cli-factory/dist/src/view.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/package.json +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/cli-host.proto +19 -19
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts +7 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js +9 -4
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js +5 -4
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts +11 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js +85 -57
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/package.json +2 -2
- package/package.json +4 -5
- package/references/native/InsightAnalyzerOptions.java +10 -0
- package/references/native/InsightAnchorScan.java +1 -11
- package/references/native/InsightCodeReferences.java +2 -3
- package/references/native/InsightCopyType.java +24 -0
- package/references/native/InsightFunctionBoundaries.java +0 -1
- package/references/native/InsightFunctionDatabases.java +20 -16
- package/references/native/InsightHelperCall.java +17 -0
- package/references/native/InsightHubServer.java +214 -0
- package/references/native/InsightNativeHost.java +112 -0
- package/references/native/InsightPlugins.java +0 -1
- package/references/native/InsightPythonWheels.java +3 -2
- package/references/native/InsightResearchQueries.java +3 -4
- package/references/native/InsightResearchView.java +4 -10
- package/references/native/InsightSdkFiles.java +7 -15
- package/references/native/InsightSdkScript.java +1 -4
- package/references/native/InsightSdkTools.java +36 -97
- package/references/native/InsightSdkTypes.java +13 -43
- package/references/native/InsightStringAnchors.java +1 -3
- package/references/native/InsightTraceState.java +13 -96
- package/references/native/InsightTraceTools.java +3 -5
- package/references/native/InsightVersionTracking.java +0 -6
- package/references/native/{HeadlessProgramMergeManager.java → InsightWcMerge.java} +17 -24
- package/references/native/InsightWcOps.java +449 -0
- package/references/native/InsightWcWorker.java +142 -0
- package/references/native/NATIVE-MERGE-NOTICE.txt +4 -8
- package/runtime/GhidraMCP-7.0.0.jar +0 -0
- package/runtime/managed/insight-heap/README.md +3 -3
- package/runtime/managed/insight-managed/README.md +3 -3
- package/runtime/native/binary/README.md +5 -4
- package/runtime/native/windows/DirectoryAlias.cs +24 -0
- package/runtime/native/windows/Insight.Windows.csproj +27 -0
- package/runtime/native/windows/Native.cs +36 -0
- package/runtime/native/windows/OwnedJob.cs +86 -0
- package/runtime/native/windows/Program.cs +50 -0
- package/runtime/native/windows/RegistryRedirect.cs +42 -0
- package/runtime/native/windows/insight-windows-x64.exe +0 -0
- package/runtime/native/windows/packages.lock.json +35 -0
- package/runtime/native/windows/provenance.json +17 -0
- package/runtime/research-view.provenance.json +6 -7
- package/runtime/toolbox.json +33 -114
- package/skill-bundle/insight-artifacts/SKILL.md +5 -19
- package/skill-bundle/insight-binary/SKILL.md +5 -35
- package/skill-bundle/insight-capture/SKILL.md +5 -45
- package/skill-bundle/insight-cli/SKILL.md +6 -44
- package/skill-bundle/insight-die/SKILL.md +5 -38
- package/skill-bundle/insight-dnspy/SKILL.md +5 -54
- package/skill-bundle/insight-dotnet-dump/SKILL.md +5 -35
- package/skill-bundle/insight-dotnet-stack/SKILL.md +5 -28
- package/skill-bundle/insight-dotnet-trace/SKILL.md +5 -34
- package/skill-bundle/insight-frida/SKILL.md +5 -56
- package/skill-bundle/insight-ghidra/SKILL.md +14 -113
- package/skill-bundle/insight-ilspy/SKILL.md +5 -34
- package/skill-bundle/insight-interop/SKILL.md +5 -43
- package/skill-bundle/insight-lldb/SKILL.md +5 -43
- package/skill-bundle/insight-llvm/SKILL.md +5 -45
- package/skill-bundle/insight-managed-heap/SKILL.md +5 -32
- package/skill-bundle/insight-managed-metadata/SKILL.md +5 -41
- package/skill-bundle/insight-mitmproxy/SKILL.md +5 -51
- package/skill-bundle/insight-overview/SKILL.md +5 -68
- package/skill-bundle/insight-procmon/SKILL.md +5 -38
- package/skill-bundle/insight-re/SKILL.md +10 -127
- package/skill-bundle/insight-sevenzip/SKILL.md +5 -31
- package/skill-bundle/insight-strace/SKILL.md +5 -35
- package/skill-bundle/insight-tshark/SKILL.md +5 -38
- package/skill-bundle/insight-windbg/SKILL.md +5 -35
- package/skill-bundle/manifest.json +1 -1
- package/skills/insight-artifacts/SKILL.md +5 -19
- package/skills/insight-binary/SKILL.md +5 -35
- package/skills/insight-capture/SKILL.md +5 -45
- package/skills/insight-die/SKILL.md +5 -38
- package/skills/insight-dnspy/SKILL.md +5 -54
- package/skills/insight-dotnet-dump/SKILL.md +5 -35
- package/skills/insight-dotnet-stack/SKILL.md +5 -28
- package/skills/insight-dotnet-trace/SKILL.md +5 -34
- package/skills/insight-frida/SKILL.md +5 -56
- package/skills/insight-ghidra/SKILL.md +14 -113
- package/skills/insight-ilspy/SKILL.md +5 -34
- package/skills/insight-interop/SKILL.md +5 -43
- package/skills/insight-lldb/SKILL.md +5 -43
- package/skills/insight-llvm/SKILL.md +5 -45
- package/skills/insight-managed-heap/SKILL.md +5 -32
- package/skills/insight-managed-metadata/SKILL.md +5 -41
- package/skills/insight-mitmproxy/SKILL.md +5 -51
- package/skills/insight-overview/SKILL.md +5 -68
- package/skills/insight-procmon/SKILL.md +5 -38
- package/skills/insight-re/SKILL.md +10 -127
- package/skills/insight-sevenzip/SKILL.md +5 -31
- package/skills/insight-strace/SKILL.md +5 -35
- package/skills/insight-tshark/SKILL.md +5 -38
- package/skills/insight-windbg/SKILL.md +5 -35
- package/dist/src/administration-results.d.ts +0 -1
- package/dist/src/administration-results.js +0 -84
- package/dist/src/administration.d.ts +0 -14
- package/dist/src/administration.js +0 -134
- package/dist/src/archive-contract.d.ts +0 -6
- package/dist/src/archive-contract.js +0 -108
- package/dist/src/archive.d.ts +0 -12
- package/dist/src/archive.js +0 -116
- package/dist/src/comment-effects.d.ts +0 -3
- package/dist/src/comment-effects.js +0 -55
- package/dist/src/context-credential.d.ts +0 -18
- package/dist/src/context-credential.js +0 -44
- package/dist/src/contexts.d.ts +0 -387
- package/dist/src/contexts.js +0 -2805
- package/dist/src/coordinator.d.ts +0 -41
- package/dist/src/coordinator.js +0 -160
- package/dist/src/cross-peer.d.ts +0 -20
- package/dist/src/cross-peer.js +0 -53
- package/dist/src/data-effects.d.ts +0 -3
- package/dist/src/data-effects.js +0 -103
- package/dist/src/debugger-caller.d.ts +0 -17
- package/dist/src/debugger-caller.js +0 -129
- package/dist/src/debugger-launch.d.ts +0 -2
- package/dist/src/debugger-launch.js +0 -17
- package/dist/src/debugger-supervisor.js +0 -179
- package/dist/src/directory-identity.d.ts +0 -6
- package/dist/src/directory-identity.js +0 -45
- package/dist/src/documentation-effects.d.ts +0 -5
- package/dist/src/documentation-effects.js +0 -56
- package/dist/src/function-effects.d.ts +0 -4
- package/dist/src/function-effects.js +0 -112
- package/dist/src/ghidra-processes.d.ts +0 -6
- package/dist/src/ghidra-processes.js +0 -138
- package/dist/src/ghidra.d.ts +0 -50
- package/dist/src/ghidra.js +0 -468
- package/dist/src/initial-model.d.ts +0 -7
- package/dist/src/initial-model.js +0 -115
- package/dist/src/initial-progress.d.ts +0 -4
- package/dist/src/initial-progress.js +0 -74
- package/dist/src/inline-script.d.ts +0 -15
- package/dist/src/inline-script.js +0 -61
- package/dist/src/legacy-migration.d.ts +0 -37
- package/dist/src/legacy-migration.js +0 -238
- package/dist/src/lifecycle.d.ts +0 -77
- package/dist/src/lifecycle.js +0 -315
- package/dist/src/merge.d.ts +0 -29
- package/dist/src/merge.js +0 -66
- package/dist/src/mutation-effects.d.ts +0 -4
- package/dist/src/mutation-effects.js +0 -321
- package/dist/src/native-queries.d.ts +0 -2
- package/dist/src/native-queries.js +0 -24
- package/dist/src/native-service.d.ts +0 -40
- package/dist/src/native-service.js +0 -406
- package/dist/src/projects.d.ts +0 -31
- package/dist/src/projects.js +0 -302
- package/dist/src/prototype-cli.d.ts +0 -8
- package/dist/src/prototype-cli.js +0 -155
- package/dist/src/query-results.d.ts +0 -2
- package/dist/src/query-results.js +0 -224
- package/dist/src/research-view.d.ts +0 -6
- package/dist/src/research-view.js +0 -9
- package/dist/src/sdk-files.d.ts +0 -29
- package/dist/src/sdk-files.js +0 -249
- package/dist/src/server.d.ts +0 -102
- package/dist/src/server.js +0 -663
- package/dist/src/storage-gc.d.ts +0 -23
- package/dist/src/storage-gc.js +0 -600
- package/dist/src/store.d.ts +0 -33
- package/dist/src/store.js +0 -178
- package/dist/src/sync-policy.d.ts +0 -22
- package/dist/src/sync-policy.js +0 -129
- package/dist/src/timed-backend.d.ts +0 -3
- package/dist/src/timed-backend.js +0 -24
- package/dist/src/timing-report.d.ts +0 -32
- package/dist/src/timing-report.js +0 -74
- package/dist/src/tool-runtime/native-process-proof.d.ts +0 -2
- package/dist/src/tool-runtime/native-process-proof.js +0 -26
- package/dist/src/transport.d.ts +0 -60
- package/dist/src/transport.js +0 -223
- package/dist/src/unresolved-guidance.d.ts +0 -46
- package/dist/src/unresolved-guidance.js +0 -55
- package/dist/src/work/backup.d.ts +0 -66
- package/dist/src/work/backup.js +0 -446
- package/dist/src/work/store.js +0 -1107
- package/dist/src/worker-lease.d.ts +0 -17
- package/dist/src/worker-lease.js +0 -50
- package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts +0 -37
- package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts.map +0 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.js.map +0 -1
- package/references/InsightRepositoryProbe.java +0 -55
- package/references/administration.md +0 -34
- package/references/agent-execution.md +0 -36
- package/references/agent-setup.md +0 -60
- package/references/archive.md +0 -32
- package/references/artifacts.md +0 -52
- package/references/debugger.md +0 -64
- package/references/extensions-and-sync.md +0 -125
- package/references/ilspy.md +0 -33
- package/references/managed-runtime.md +0 -162
- package/references/native/InsightArchivePayloads.java +0 -36
- package/references/native/InsightBlockTransfer.java +0 -57
- package/references/native/InsightGuiMain.java +0 -33
- package/references/native/InsightHeadlessMain.java +0 -18
- package/references/native/InsightImportProgress.java +0 -60
- package/references/native/InsightInitialImport.java +0 -48
- package/references/native/InsightInitialJournal.java +0 -57
- package/references/native/InsightInitialPublication.java +0 -142
- package/references/native/InsightInitialRecovery.java +0 -131
- package/references/native/InsightInlineExecutor.java +0 -143
- package/references/native/InsightInlineScript.java +0 -14
- package/references/native/InsightNativeCheckout.java +0 -487
- package/references/native/InsightNativeFingerprint.java +0 -80
- package/references/native/InsightNativeMigration.java +0 -155
- package/references/native/InsightNativeRead.java +0 -80
- package/references/native/InsightNativeReceipt.java +0 -31
- package/references/native/InsightNativeService.java +0 -43
- package/references/native/InsightNativeView.java +0 -40
- package/references/native/InsightOfflineAuthenticator.java +0 -20
- package/references/native/InsightOwnedScripts.java +0 -170
- package/references/native/InsightProjectFiles.java +0 -92
- package/references/native/InsightPublicationRecovery.java +0 -63
- package/references/native/InsightServerAdministration.java +0 -82
- package/references/native/InsightServerInit.java +0 -62
- package/references/native/InsightServerMain.java +0 -43
- package/references/native/InsightServerProbe.java +0 -29
- package/references/native/InsightSnapshotFields.java +0 -74
- package/references/native/InsightSnapshotInspect.java +0 -191
- package/references/native/InsightSnapshotPublisher.java +0 -123
- package/references/native/InsightStopDebugger.java +0 -20
- package/references/native/InsightTraceInspect.java +0 -24
- package/references/native/InsightWorkerLease.java +0 -132
- package/references/native-workflows.md +0 -124
- package/references/persistent-client.mjs +0 -147
- package/references/persistent.md +0 -90
- package/references/query-semantics.md +0 -109
- package/references/recovery.md +0 -235
- package/references/research.md +0 -296
- package/references/setup.md +0 -135
- package/references/sparse-navigation.md +0 -173
- package/references/storage.md +0 -139
- package/references/work-tracking.md +0 -261
- package/runtime/native/file-version.ps1 +0 -7
- package/runtime/native/mitmproxy/bridge.py +0 -180
- package/runtime/native/windows-job/DirectoryAlias.cs +0 -24
- package/runtime/native/windows-job/Insight.WindowsJob.csproj +0 -1
- package/runtime/native/windows-job/Insight.WindowsJob.dll +0 -0
- package/runtime/native/windows-job/OwnedJob.cs +0 -79
- package/runtime/native/windows-job/RegistryRedirect.cs +0 -45
- package/runtime/native/windows-job/packages.lock.json +0 -21
- package/runtime/native/windows-job/provenance.json +0 -16
- package/runtime/native/windows-job/windows-job.ps1 +0 -8
- package/skill-bundle/insight-artifacts/references/agent-execution.md +0 -36
- package/skill-bundle/insight-artifacts/references/artifacts.md +0 -52
- package/skill-bundle/insight-artifacts/references/recovery.md +0 -235
- package/skill-bundle/insight-artifacts/references/storage.md +0 -139
- package/skill-bundle/insight-binary/references/agent-execution.md +0 -36
- package/skill-bundle/insight-capture/references/agent-execution.md +0 -36
- package/skill-bundle/insight-cli/references/agent-execution.md +0 -36
- package/skill-bundle/insight-cli/references/agent-setup.md +0 -60
- package/skill-bundle/insight-cli/references/archive.md +0 -32
- package/skill-bundle/insight-cli/references/managed-runtime.md +0 -162
- package/skill-bundle/insight-cli/references/persistent-client.mjs +0 -147
- package/skill-bundle/insight-cli/references/persistent.md +0 -90
- package/skill-bundle/insight-cli/references/recovery.md +0 -235
- package/skill-bundle/insight-cli/references/setup.md +0 -135
- package/skill-bundle/insight-cli/references/storage.md +0 -139
- package/skill-bundle/insight-die/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dnspy/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dotnet-dump/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dotnet-stack/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dotnet-trace/references/agent-execution.md +0 -36
- package/skill-bundle/insight-frida/references/agent-execution.md +0 -36
- package/skill-bundle/insight-ghidra/references/administration.md +0 -34
- package/skill-bundle/insight-ghidra/references/agent-execution.md +0 -36
- package/skill-bundle/insight-ghidra/references/archive.md +0 -32
- package/skill-bundle/insight-ghidra/references/artifacts.md +0 -52
- package/skill-bundle/insight-ghidra/references/debugger.md +0 -64
- package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +0 -125
- package/skill-bundle/insight-ghidra/references/managed-runtime.md +0 -162
- package/skill-bundle/insight-ghidra/references/native-workflows.md +0 -124
- package/skill-bundle/insight-ghidra/references/persistent-client.mjs +0 -147
- package/skill-bundle/insight-ghidra/references/persistent.md +0 -90
- package/skill-bundle/insight-ghidra/references/query-semantics.md +0 -109
- package/skill-bundle/insight-ghidra/references/recovery.md +0 -235
- package/skill-bundle/insight-ghidra/references/research.md +0 -296
- package/skill-bundle/insight-ghidra/references/setup.md +0 -135
- package/skill-bundle/insight-ghidra/references/sparse-navigation.md +0 -173
- package/skill-bundle/insight-ghidra/references/storage.md +0 -139
- package/skill-bundle/insight-ilspy/references/agent-execution.md +0 -36
- package/skill-bundle/insight-ilspy/references/ilspy.md +0 -33
- package/skill-bundle/insight-interop/references/agent-execution.md +0 -36
- package/skill-bundle/insight-lldb/references/agent-execution.md +0 -36
- package/skill-bundle/insight-llvm/references/agent-execution.md +0 -36
- package/skill-bundle/insight-managed-heap/references/agent-execution.md +0 -36
- package/skill-bundle/insight-managed-metadata/references/agent-execution.md +0 -36
- package/skill-bundle/insight-mitmproxy/references/agent-execution.md +0 -36
- package/skill-bundle/insight-overview/references/agent-execution.md +0 -36
- package/skill-bundle/insight-procmon/references/agent-execution.md +0 -36
- package/skill-bundle/insight-re/references/agent-execution.md +0 -36
- package/skill-bundle/insight-re/references/artifacts.md +0 -52
- package/skill-bundle/insight-re/references/persistent-client.mjs +0 -147
- package/skill-bundle/insight-re/references/persistent.md +0 -90
- package/skill-bundle/insight-re/references/recovery.md +0 -235
- package/skill-bundle/insight-re/references/storage.md +0 -139
- package/skill-bundle/insight-re/references/work-tracking.md +0 -261
- package/skill-bundle/insight-sevenzip/references/agent-execution.md +0 -36
- package/skill-bundle/insight-strace/references/agent-execution.md +0 -36
- package/skill-bundle/insight-tshark/references/agent-execution.md +0 -36
- package/skill-bundle/insight-windbg/references/agent-execution.md +0 -36
- package/skills/insight-artifacts/references/agent-execution.md +0 -36
- package/skills/insight-artifacts/references/artifacts.md +0 -52
- package/skills/insight-artifacts/references/recovery.md +0 -235
- package/skills/insight-artifacts/references/storage.md +0 -139
- package/skills/insight-binary/references/agent-execution.md +0 -36
- package/skills/insight-capture/references/agent-execution.md +0 -36
- package/skills/insight-die/references/agent-execution.md +0 -36
- package/skills/insight-dnspy/references/agent-execution.md +0 -36
- package/skills/insight-dotnet-dump/references/agent-execution.md +0 -36
- package/skills/insight-dotnet-stack/references/agent-execution.md +0 -36
- package/skills/insight-dotnet-trace/references/agent-execution.md +0 -36
- package/skills/insight-frida/references/agent-execution.md +0 -36
- package/skills/insight-ghidra/references/administration.md +0 -34
- package/skills/insight-ghidra/references/agent-execution.md +0 -36
- package/skills/insight-ghidra/references/archive.md +0 -32
- package/skills/insight-ghidra/references/artifacts.md +0 -52
- package/skills/insight-ghidra/references/debugger.md +0 -64
- package/skills/insight-ghidra/references/extensions-and-sync.md +0 -125
- package/skills/insight-ghidra/references/managed-runtime.md +0 -162
- package/skills/insight-ghidra/references/native-workflows.md +0 -124
- package/skills/insight-ghidra/references/persistent-client.mjs +0 -147
- package/skills/insight-ghidra/references/persistent.md +0 -90
- package/skills/insight-ghidra/references/query-semantics.md +0 -109
- package/skills/insight-ghidra/references/recovery.md +0 -235
- package/skills/insight-ghidra/references/research.md +0 -296
- package/skills/insight-ghidra/references/setup.md +0 -135
- package/skills/insight-ghidra/references/sparse-navigation.md +0 -173
- package/skills/insight-ghidra/references/storage.md +0 -139
- package/skills/insight-ilspy/references/agent-execution.md +0 -36
- package/skills/insight-ilspy/references/ilspy.md +0 -33
- package/skills/insight-interop/references/agent-execution.md +0 -36
- package/skills/insight-lldb/references/agent-execution.md +0 -36
- package/skills/insight-llvm/references/agent-execution.md +0 -36
- package/skills/insight-managed-heap/references/agent-execution.md +0 -36
- package/skills/insight-managed-metadata/references/agent-execution.md +0 -36
- package/skills/insight-mitmproxy/references/agent-execution.md +0 -36
- package/skills/insight-overview/references/agent-execution.md +0 -36
- package/skills/insight-procmon/references/agent-execution.md +0 -36
- package/skills/insight-re/references/agent-execution.md +0 -36
- package/skills/insight-re/references/artifacts.md +0 -52
- package/skills/insight-re/references/persistent-client.mjs +0 -147
- package/skills/insight-re/references/persistent.md +0 -90
- package/skills/insight-re/references/recovery.md +0 -235
- package/skills/insight-re/references/storage.md +0 -139
- package/skills/insight-re/references/work-tracking.md +0 -261
- package/skills/insight-sevenzip/references/agent-execution.md +0 -36
- package/skills/insight-strace/references/agent-execution.md +0 -36
- package/skills/insight-tshark/references/agent-execution.md +0 -36
- package/skills/insight-windbg/references/agent-execution.md +0 -36
- /package/dist/src/{debugger-supervisor.d.ts → native/contract.js} +0 -0
- /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 {
|
|
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
|
|
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
|
|
78
|
-
|
|
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'
|
|
66
|
+
entries.push({ ...base, kind: 'file' });
|
|
90
67
|
else if (st.isSymbolicLink()) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
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
|
-
|
|
146
|
-
|
|
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
|
-
|
|
169
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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.
|
|
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 (
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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:
|
|
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
|
-
|
|
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 =
|
|
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
|
|
270
|
-
throw new CliError('
|
|
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,
|
|
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,
|
|
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
|
-
|
|
309
|
-
|
|
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
|
-
|
|
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
|
|
336
|
-
|
|
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
|
-
|
|
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 (
|
|
384
|
-
|
|
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
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
419
|
-
if (
|
|
420
|
-
|
|
421
|
-
|
|
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
|
-
|
|
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
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
|
476
|
-
await sync(
|
|
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
|
|
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
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
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
|
|
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' }] }),
|