@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
package/dist/src/storage-gc.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Workspace, type GhidraContext } from './workspace.js';
|
|
2
|
-
/** Deletes only bytes reproducible from retained state. Anything unproved is reported and kept. */
|
|
3
|
-
export interface CollectionPort {
|
|
4
|
-
closed(context: GhidraContext): Promise<boolean>;
|
|
5
|
-
/** Verify natively that a stopped checkout has no work, then release and drop its project. */
|
|
6
|
-
release(context: GhidraContext): Promise<boolean>;
|
|
7
|
-
}
|
|
8
|
-
export interface Category {
|
|
9
|
-
items: number;
|
|
10
|
-
bytes: number;
|
|
11
|
-
}
|
|
12
|
-
export declare function collectStorage(workspace: Workspace, port: CollectionPort, dryRun: boolean, progress?: (message: string) => void): Promise<{
|
|
13
|
-
retained: {
|
|
14
|
-
path: string;
|
|
15
|
-
reason: string;
|
|
16
|
-
}[];
|
|
17
|
-
id?: `${string}-${string}-${string}-${string}-${string}` | undefined;
|
|
18
|
-
state: string;
|
|
19
|
-
dryRun: boolean;
|
|
20
|
-
bytes: number;
|
|
21
|
-
categories: Record<string, Category>;
|
|
22
|
-
retainedCount: number;
|
|
23
|
-
}>;
|
package/dist/src/storage-gc.js
DELETED
|
@@ -1,600 +0,0 @@
|
|
|
1
|
-
import { lstat, mkdir, open, readdir, readFile, realpath, rename, rm, unlink } from 'node:fs/promises';
|
|
2
|
-
import { join, relative } from 'node:path';
|
|
3
|
-
import { auditEvent, auditHash } from './activity-audit.js';
|
|
4
|
-
import { createHash, randomUUID } from 'node:crypto';
|
|
5
|
-
import { createReadStream } from 'node:fs';
|
|
6
|
-
import { stable } from './model.js';
|
|
7
|
-
import { peerStages } from './cross-peer.js';
|
|
8
|
-
import { sameDirectory } from './directory-identity.js';
|
|
9
|
-
const missing = (error) => error.code === 'ENOENT';
|
|
10
|
-
const uuid = '[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}';
|
|
11
|
-
const artifactName = /^([a-f0-9]{64})\.(gzf|json)$/, pendingName = new RegExp('^pending-' + uuid + '$');
|
|
12
|
-
const exportName = new RegExp('^(?:saved-' + uuid + '|shared|recovered)\\.gzf$');
|
|
13
|
-
async function linked(path) { try {
|
|
14
|
-
return (await lstat(path)).isSymbolicLink();
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
if (missing(error))
|
|
18
|
-
return false;
|
|
19
|
-
throw error;
|
|
20
|
-
} }
|
|
21
|
-
async function directories(path) {
|
|
22
|
-
if (await linked(path))
|
|
23
|
-
return [];
|
|
24
|
-
try {
|
|
25
|
-
return (await readdir(path, { withFileTypes: true })).filter(e => e.isDirectory()).map(e => e.name);
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
if (missing(error))
|
|
29
|
-
return [];
|
|
30
|
-
throw error;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function files(path) {
|
|
34
|
-
if (await linked(path))
|
|
35
|
-
return [];
|
|
36
|
-
try {
|
|
37
|
-
return (await readdir(path, { withFileTypes: true })).filter(e => e.isFile()).map(e => e.name);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (missing(error))
|
|
41
|
-
return [];
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async function present(path) { try {
|
|
46
|
-
return await lstat(path);
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
if (missing(error))
|
|
50
|
-
return;
|
|
51
|
-
throw error;
|
|
52
|
-
} }
|
|
53
|
-
async function json(path) {
|
|
54
|
-
try {
|
|
55
|
-
const value = JSON.parse(await readFile(path, 'utf8'));
|
|
56
|
-
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
if (missing(error) || error instanceof SyntaxError)
|
|
60
|
-
return;
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function alive(pid) { try {
|
|
65
|
-
process.kill(pid, 0);
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
return error.code !== 'ESRCH';
|
|
70
|
-
} }
|
|
71
|
-
async function older(path, ms) { const st = await present(path); return st !== undefined && Date.now() - st.mtimeMs > ms; }
|
|
72
|
-
/** A hard link frees its bytes only when every name of that file is removed. */
|
|
73
|
-
class Reclaimed {
|
|
74
|
-
seen = new Map();
|
|
75
|
-
async add(path, category) {
|
|
76
|
-
const st = await lstat(path, { bigint: true });
|
|
77
|
-
if (st.isDirectory()) {
|
|
78
|
-
for (const name of await readdir(path))
|
|
79
|
-
await this.add(join(path, name), category);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (!st.isFile())
|
|
83
|
-
return;
|
|
84
|
-
const key = st.dev + ':' + st.ino, row = this.seen.get(key);
|
|
85
|
-
// A real run removes names as it goes, so keep the first observed link count.
|
|
86
|
-
if (row)
|
|
87
|
-
row.names++;
|
|
88
|
-
else
|
|
89
|
-
this.seen.set(key, { links: Number(st.nlink), names: 1, size: Number(st.size), category });
|
|
90
|
-
}
|
|
91
|
-
include(other) {
|
|
92
|
-
for (const [key, value] of other.seen) {
|
|
93
|
-
const row = this.seen.get(key);
|
|
94
|
-
if (row)
|
|
95
|
-
row.names += value.names;
|
|
96
|
-
else
|
|
97
|
-
this.seen.set(key, value);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
bytes() { const out = {}; for (const f of this.seen.values())
|
|
101
|
-
if (f.names >= f.links)
|
|
102
|
-
out[f.category] = (out[f.category] ?? 0) + f.size; return out; }
|
|
103
|
-
}
|
|
104
|
-
async function stopReceipt(root, worker) {
|
|
105
|
-
const stop = await json(join(root, 'stopped.json'));
|
|
106
|
-
return stop && stop.pid === worker.pid && stop.tokenSecret === worker.tokenSecret ? stop : undefined;
|
|
107
|
-
}
|
|
108
|
-
async function stopped(root, worker) {
|
|
109
|
-
if (!Number.isSafeInteger(worker.pid) || Number(worker.pid) < 1)
|
|
110
|
-
return false;
|
|
111
|
-
return Boolean(await stopReceipt(root, worker)) || !alive(Number(worker.pid));
|
|
112
|
-
}
|
|
113
|
-
/** A detached private project is redundant only while it holds just its one imported program. */
|
|
114
|
-
async function soleProgram(root) {
|
|
115
|
-
let count = 0;
|
|
116
|
-
async function walk(path) {
|
|
117
|
-
let entries;
|
|
118
|
-
try {
|
|
119
|
-
entries = await readdir(path, { withFileTypes: true });
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
if (missing(error))
|
|
123
|
-
return;
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
for (const e of entries) {
|
|
127
|
-
if (e.isDirectory())
|
|
128
|
-
await walk(join(path, e.name));
|
|
129
|
-
else if (e.name.endsWith('.prp') && e.name !== 'project.prp')
|
|
130
|
-
count++;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
for (const tree of ['idata', 'versioned', 'user'])
|
|
134
|
-
await walk(join(root, 'view.rep', tree));
|
|
135
|
-
return count <= 1;
|
|
136
|
-
}
|
|
137
|
-
/** A native receipt describes bytes elsewhere; only a verified full packed program proves detached capture. */
|
|
138
|
-
async function detachedCapture(workspace, root, candidates) {
|
|
139
|
-
try {
|
|
140
|
-
const path = join(root, 'saved.gzf'), st = await present(path);
|
|
141
|
-
if (!st?.isFile() || st.isSymbolicLink())
|
|
142
|
-
return false;
|
|
143
|
-
const possible = candidates.filter(a => a.kind === 'snapshot' && a.size === st.size);
|
|
144
|
-
if (!possible.length)
|
|
145
|
-
return false;
|
|
146
|
-
const hash = createHash('sha256');
|
|
147
|
-
for await (const chunk of createReadStream(path))
|
|
148
|
-
hash.update(chunk);
|
|
149
|
-
const sha = hash.digest('hex');
|
|
150
|
-
for (const artifact of possible)
|
|
151
|
-
if (artifact.sha256 === sha)
|
|
152
|
-
try {
|
|
153
|
-
await workspace.artifacts.verify(artifact);
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
catch { /* Try another retained full copy. */ }
|
|
157
|
-
}
|
|
158
|
-
catch { /* Unreadable or changing capture bytes never authorize project removal. */ }
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
async function durable(path, value) {
|
|
162
|
-
const temporary = path + '.new-' + randomUUID(), file = await open(temporary, 'wx', 0o600);
|
|
163
|
-
try {
|
|
164
|
-
await file.writeFile(stable(value));
|
|
165
|
-
await file.sync();
|
|
166
|
-
}
|
|
167
|
-
finally {
|
|
168
|
-
await file.close();
|
|
169
|
-
}
|
|
170
|
-
await rename(temporary, path);
|
|
171
|
-
}
|
|
172
|
-
export async function collectStorage(workspace, port, dryRun, progress = () => { }) {
|
|
173
|
-
const native = join(workspace.directory, 'ghidra-native'), retained = [];
|
|
174
|
-
const reclaimed = new Reclaimed(), categories = {};
|
|
175
|
-
const id = randomUUID(), receipt = join(workspace.directory, 'gc', id + '.json'), startedAt = new Date().toISOString();
|
|
176
|
-
auditEvent('gc.started', { gcId: id, dryRun });
|
|
177
|
-
try {
|
|
178
|
-
if (!dryRun) {
|
|
179
|
-
await mkdir(join(workspace.directory, 'gc'), { recursive: true, mode: 0o700 });
|
|
180
|
-
await durable(receipt, { schema: 1, id, state: 'started', startedAt });
|
|
181
|
-
}
|
|
182
|
-
const resource = (path) => {
|
|
183
|
-
try {
|
|
184
|
-
const locator = relative(workspace.directory, path).replaceAll('\\', '/'), artifact = /^artifacts\/([a-f0-9]{64})\.(gzf|json)$/.exec(locator), context = /^ghidra-native\/context\/(c_[a-f0-9-]{36})\//i.exec(locator);
|
|
185
|
-
return { gcId: id, dryRun, resourceHash: auditHash(locator), ...(context ? { context: context[1] } : {}), ...(artifact ? { artifact: (artifact[2] === 'gzf' ? 'snapshot:' : 'native:') + artifact[1], resourceType: artifact[2] === 'gzf' ? 'snapshot' : 'native-view' } : { resourceType: locator.endsWith('view.rep') || locator.endsWith('view.gpr') ? 'project' : locator.endsWith('.gzf') ? 'export' : locator.endsWith('.cache') ? 'cache' : 'other' }) };
|
|
186
|
-
}
|
|
187
|
-
catch {
|
|
188
|
-
return { gcId: id, dryRun };
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
const keep = (path, reason) => {
|
|
192
|
-
retained.push({ path, reason });
|
|
193
|
-
const code = /[Pp]rivate|differs|additional files/.test(reason) ? 'private-work' : /[Ww]orker|opening|recovery|uncertain|unsettled|unresolved|debugger/.test(reason) ? 'live-or-uncertain' : /reference/.test(reason) ? 'referenced' : /ownership|owner|receipt|unverif/.test(reason) ? 'ownership-unproved' : /private|differs/.test(reason) ? 'private-work' : /capture/.test(reason) ? 'capture-unproved' : /Links/.test(reason) ? 'link-or-special' : /Removal/.test(reason) ? 'removal-failed' : 'other';
|
|
194
|
-
auditEvent('gc.retained', { ...resource(path), reason: code });
|
|
195
|
-
};
|
|
196
|
-
async function remove(path, category) {
|
|
197
|
-
const st = await present(path);
|
|
198
|
-
if (!st)
|
|
199
|
-
return true;
|
|
200
|
-
if (st.isSymbolicLink() || !st.isFile() && !st.isDirectory()) {
|
|
201
|
-
keep(path, 'Links and special entries are never removed.');
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
const sizes = new Reclaimed();
|
|
205
|
-
await sizes.add(path, category);
|
|
206
|
-
auditEvent(dryRun ? 'gc.remove.planned' : 'gc.remove.started', { ...resource(path), category });
|
|
207
|
-
if (!dryRun)
|
|
208
|
-
try {
|
|
209
|
-
if (st.isDirectory())
|
|
210
|
-
await rm(path, { recursive: true, maxRetries: 3 });
|
|
211
|
-
else
|
|
212
|
-
await unlink(path);
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
auditEvent('gc.remove.failed', { ...resource(path), category, error, outcome: 'failure' });
|
|
216
|
-
keep(path, 'Removal failed: ' + String(error.code));
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
if (!dryRun)
|
|
220
|
-
auditEvent('gc.remove.succeeded', { ...resource(path), category, outcome: 'success' });
|
|
221
|
-
reclaimed.include(sizes);
|
|
222
|
-
(categories[category] ??= { items: 0, bytes: 0 }).items++;
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
// A context participates only when nothing about its private state is uncertain.
|
|
226
|
-
const contexts = workspace.allContexts(), safe = new Set(), blockedTargets = new Set(), unsettled = new Set();
|
|
227
|
-
const nativeRoots = new Set(contexts.flatMap(c => c.nativeCheckout ? [c.nativeCheckout.root] : [])), artifacts = workspace.allArtifacts(), nativeEvidence = new Set(), nativeProjects = new Map();
|
|
228
|
-
let unverifiedNativeReceipt = false;
|
|
229
|
-
for (const artifact of artifacts)
|
|
230
|
-
if (artifact.kind === 'native')
|
|
231
|
-
try {
|
|
232
|
-
const view = await json(await workspace.artifacts.verify(artifact));
|
|
233
|
-
if (!view) {
|
|
234
|
-
unverifiedNativeReceipt = true;
|
|
235
|
-
nativeEvidence.add(artifact.id);
|
|
236
|
-
}
|
|
237
|
-
else if (view.source === 'checkout') {
|
|
238
|
-
const checkout = view.checkout;
|
|
239
|
-
if (typeof checkout?.root === 'string') {
|
|
240
|
-
nativeRoots.add(checkout.root);
|
|
241
|
-
nativeProjects.set(artifact.id, checkout.root);
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
unverifiedNativeReceipt = true;
|
|
245
|
-
nativeEvidence.add(artifact.id);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
catch {
|
|
250
|
-
unverifiedNativeReceipt = true;
|
|
251
|
-
nativeEvidence.add(artifact.id);
|
|
252
|
-
}
|
|
253
|
-
for (const context of contexts) {
|
|
254
|
-
const active = workspace.activePublication(context.target);
|
|
255
|
-
let reason;
|
|
256
|
-
if (active)
|
|
257
|
-
blockedTargets.add(context.target);
|
|
258
|
-
if (['opening', 'needs_recovery'].includes(context.state))
|
|
259
|
-
reason = 'Context is still opening or requires recovery.';
|
|
260
|
-
else if (workspace.unresolved(context).length || workspace.uncertainOutcome(context))
|
|
261
|
-
reason = 'Context has an unresolved or uncertain operation.';
|
|
262
|
-
else if (active?.session === context.session)
|
|
263
|
-
reason = 'Context has an unresolved publication.';
|
|
264
|
-
else if (context.debugger?.traces.length || context.debugger?.connected)
|
|
265
|
-
reason = 'Context retains debugger state.';
|
|
266
|
-
else {
|
|
267
|
-
try {
|
|
268
|
-
if (!await port.closed(context))
|
|
269
|
-
reason = 'Context worker is not proved stopped.';
|
|
270
|
-
}
|
|
271
|
-
catch {
|
|
272
|
-
reason = 'Context worker receipt could not be verified.';
|
|
273
|
-
}
|
|
274
|
-
if (!reason && context.workingSnapshot)
|
|
275
|
-
try {
|
|
276
|
-
await workspace.artifacts.verify(context.workingSnapshot);
|
|
277
|
-
}
|
|
278
|
-
catch {
|
|
279
|
-
reason = 'Saved private view could not be verified.';
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
if (reason) {
|
|
283
|
-
keep(join(native, 'context', context.id), reason);
|
|
284
|
-
unsettled.add(context.target);
|
|
285
|
-
}
|
|
286
|
-
else
|
|
287
|
-
safe.add(context.id);
|
|
288
|
-
}
|
|
289
|
-
// Ghidra releases clean checkouts itself; their projects are never deleted behind its back.
|
|
290
|
-
for (const context of contexts) {
|
|
291
|
-
const checkout = context.nativeCheckout, category = 'native-checkouts';
|
|
292
|
-
if (!checkout || checkout.state === 'dropped' || !safe.has(context.id) || checkout.conflict || context.scalars.length || context.complexChanges.length)
|
|
293
|
-
continue;
|
|
294
|
-
if (checkout.state === 'active' && !await present(checkout.root)) {
|
|
295
|
-
keep(checkout.root, 'Native checkout project is missing; its server checkout is retained.');
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
try {
|
|
299
|
-
const owner = join(checkout.root, 'native-owner.json');
|
|
300
|
-
if (await linked(owner) || !await json(owner)) {
|
|
301
|
-
keep(checkout.root, 'Native ownership receipt is missing or unverifiable; its checkout is retained.');
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
catch {
|
|
306
|
-
keep(checkout.root, 'Native ownership receipt could not be verified; its checkout is retained.');
|
|
307
|
-
continue;
|
|
308
|
-
}
|
|
309
|
-
if (workspace.checkoutReferenced(context)) {
|
|
310
|
-
keep(checkout.root, 'An unresolved operation in another context references this checkout.');
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
const project = join(checkout.root, 'view.rep');
|
|
314
|
-
if (dryRun) {
|
|
315
|
-
if (workspace.unchangedNative(context))
|
|
316
|
-
await remove(project, category);
|
|
317
|
-
else
|
|
318
|
-
keep(checkout.root, 'Ghidra did not report this checkout unmodified when it was last saved or observed; it may hold private work.');
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
const sizes = new Reclaimed();
|
|
322
|
-
if (await present(project))
|
|
323
|
-
await sizes.add(project, category);
|
|
324
|
-
try {
|
|
325
|
-
progress('Verifying native checkout ' + context.session + ' / ' + context.target);
|
|
326
|
-
auditEvent('gc.release.started', { ...resource(checkout.root), category, ...context, context: context.id });
|
|
327
|
-
if (await port.release(context)) {
|
|
328
|
-
const row = categories[category] ??= { items: 0, bytes: 0 };
|
|
329
|
-
row.items++;
|
|
330
|
-
row.bytes += sizes.bytes()[category] ?? 0;
|
|
331
|
-
auditEvent('gc.release.succeeded', { ...resource(checkout.root), category, outcome: 'success', ...context, context: context.id });
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
auditEvent('gc.release.failed', { ...resource(checkout.root), category, reason: 'capture-unproved', outcome: 'failure', ...context, context: context.id });
|
|
335
|
-
keep(checkout.root, 'Native checkout is not proved unchanged.');
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
catch (error) {
|
|
339
|
-
auditEvent('gc.release.failed', { ...resource(checkout.root), category, error, outcome: 'failure', ...context, context: context.id });
|
|
340
|
-
keep(checkout.root, 'Native release was refused: ' + String(error.message).slice(0, 300));
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
const known = new Set(contexts.map(c => c.id)), captured = new Map(), targetCaptures = new Map(), discarded = new Set(), disposedDetachedRoots = new Set();
|
|
344
|
-
for (const context of contexts) {
|
|
345
|
-
const snapshots = [];
|
|
346
|
-
if (context.workingSnapshot?.kind === 'snapshot')
|
|
347
|
-
snapshots.push(context.workingSnapshot);
|
|
348
|
-
try {
|
|
349
|
-
const migration = await json(join(workspace.directory, 'legacy-migrations', context.target, context.id + '-detached.json'));
|
|
350
|
-
const original = migration?.original;
|
|
351
|
-
if (migration?.schema === 1 && original?.id === context.id && original.target === context.target && !original.nativeCheckout && original.workingSnapshot?.kind === 'snapshot')
|
|
352
|
-
snapshots.push(original.workingSnapshot);
|
|
353
|
-
}
|
|
354
|
-
catch { /* A damaged migration receipt does not prove a detached capture. */ }
|
|
355
|
-
captured.set(context.id, snapshots);
|
|
356
|
-
targetCaptures.set(context.target, [...(targetCaptures.get(context.target) ?? []), ...snapshots]);
|
|
357
|
-
}
|
|
358
|
-
// Only detached roots are reached by the project rule, and a discarded context holds no others.
|
|
359
|
-
for (const context of contexts)
|
|
360
|
-
if (workspace.legacyDiscarded(context))
|
|
361
|
-
discarded.add(context.id);
|
|
362
|
-
for (const kind of ['context', 'shared', 'candidate']) {
|
|
363
|
-
const parent = join(native, kind);
|
|
364
|
-
for (const owner of await directories(parent)) {
|
|
365
|
-
if (kind === 'context' && !safe.has(owner)) {
|
|
366
|
-
if (!known.has(owner))
|
|
367
|
-
keep(join(parent, owner), 'Directory has no matching context.');
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
if (kind !== 'context' && blockedTargets.has(owner)) {
|
|
371
|
-
keep(join(parent, owner), 'Target has an unresolved publication.');
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
// A merge or refresh interrupted before its publication row still owns candidate evidence.
|
|
375
|
-
if (kind === 'candidate' && unsettled.has(owner)) {
|
|
376
|
-
keep(join(parent, owner), 'Target has an unsettled context.');
|
|
377
|
-
continue;
|
|
378
|
-
}
|
|
379
|
-
for (const name of await directories(join(parent, owner))) {
|
|
380
|
-
const root = join(parent, owner, name);
|
|
381
|
-
if (await realpath(root) !== join(await realpath(parent), owner, name)) {
|
|
382
|
-
keep(root, 'Working root moved outside owned storage.');
|
|
383
|
-
continue;
|
|
384
|
-
}
|
|
385
|
-
let worker, nativeRoot = false, projectOwnershipReason;
|
|
386
|
-
try {
|
|
387
|
-
const ownerPresent = Boolean(await present(join(root, 'native-owner.json')));
|
|
388
|
-
const creationPath = join(parent, owner, 'checkout.json');
|
|
389
|
-
if (kind === 'context' && await linked(creationPath)) {
|
|
390
|
-
keep(root, 'Native creation receipt is linked; project ownership is unproved.');
|
|
391
|
-
continue;
|
|
392
|
-
}
|
|
393
|
-
const creation = kind === 'context' ? await json(creationPath) : undefined;
|
|
394
|
-
const creationPresent = kind === 'context' && Boolean(await present(creationPath));
|
|
395
|
-
const creationRoot = creation?.root;
|
|
396
|
-
let locatorUnverified = false;
|
|
397
|
-
const locators = [...nativeRoots, ...(typeof creationRoot === 'string' ? [creationRoot] : [])];
|
|
398
|
-
const recordedNative = !ownerPresent && locators.some(named => {
|
|
399
|
-
if (named === root)
|
|
400
|
-
return true;
|
|
401
|
-
try {
|
|
402
|
-
return sameDirectory(named, root);
|
|
403
|
-
}
|
|
404
|
-
catch (error) {
|
|
405
|
-
if (!missing(error))
|
|
406
|
-
locatorUnverified = true;
|
|
407
|
-
return false;
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
if (!ownerPresent && (recordedNative || locatorUnverified || (creationPresent && typeof creationRoot !== 'string') || unverifiedNativeReceipt)) {
|
|
411
|
-
projectOwnershipReason = 'Native checkout or creation ownership is missing or unverifiable; detached cleanup is not authorized.';
|
|
412
|
-
}
|
|
413
|
-
worker = await json(join(root, 'process.json'));
|
|
414
|
-
nativeRoot = ownerPresent;
|
|
415
|
-
if (!worker && !nativeRoot) {
|
|
416
|
-
keep(root, 'Working root has no worker receipt.');
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
if (worker && (worker.kind !== kind || (kind === 'context' ? worker.context : worker.target) !== owner)) {
|
|
420
|
-
keep(root, 'Worker receipt belongs to a different owner.');
|
|
421
|
-
continue;
|
|
422
|
-
}
|
|
423
|
-
if (worker && !await stopped(root, worker)) {
|
|
424
|
-
keep(root, 'Worker is not proved stopped.');
|
|
425
|
-
continue;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
catch (error) {
|
|
429
|
-
keep(root, 'Working root worker proof could not be verified: ' + String(error.code ?? 'unavailable'));
|
|
430
|
-
continue;
|
|
431
|
-
}
|
|
432
|
-
for (const name of ['ghidra', 'exports', 'explicit-exports'])
|
|
433
|
-
if (await linked(join(root, name)))
|
|
434
|
-
keep(join(root, name), 'Links and special entries are never removed.');
|
|
435
|
-
if (kind === 'context') {
|
|
436
|
-
const context = workspace.contextById(owner), stages = await peerStages(root, { context: owner, target: context.target });
|
|
437
|
-
let ownershipReason;
|
|
438
|
-
if (stages.length)
|
|
439
|
-
try {
|
|
440
|
-
const linkedOwner = await linked(join(root, 'process.json')) || await linked(join(root, 'native-owner.json'));
|
|
441
|
-
const nativeOwner = nativeRoot && !linkedOwner && (await lstat(join(root, 'native-owner.json'))).isFile() ? await json(join(root, 'native-owner.json')) : undefined;
|
|
442
|
-
if (!worker)
|
|
443
|
-
ownershipReason = 'Cross-target working root has no worker receipt that proves it stopped.';
|
|
444
|
-
else if (linkedOwner)
|
|
445
|
-
ownershipReason = 'Cross-target working root ownership receipt is a link.';
|
|
446
|
-
else if (worker && worker.target !== context.target || nativeRoot && (!nativeOwner || nativeOwner.context !== owner || nativeOwner.target !== context.target))
|
|
447
|
-
ownershipReason = 'Cross-target working root receipt belongs to a different owner.';
|
|
448
|
-
else if (typeof worker.root !== 'string' || !sameDirectory(worker.root, root))
|
|
449
|
-
ownershipReason = 'Cross-target worker receipt does not identify this working root.';
|
|
450
|
-
}
|
|
451
|
-
catch (error) {
|
|
452
|
-
ownershipReason = 'Cross-target working root ownership receipt could not be verified: ' + String(error.code ?? 'unavailable');
|
|
453
|
-
}
|
|
454
|
-
for (const stage of stages) {
|
|
455
|
-
if (ownershipReason)
|
|
456
|
-
keep(stage.folder, ownershipReason);
|
|
457
|
-
else if ('reason' in stage)
|
|
458
|
-
keep(stage.folder, stage.reason);
|
|
459
|
-
else if (stage.receipt.state !== 'closed')
|
|
460
|
-
keep(stage.folder, 'Cross-target cleanup is incomplete; its temporary program removal is unverified.');
|
|
461
|
-
else if (workspace.checkoutReferenced(context, root))
|
|
462
|
-
keep(stage.folder, 'An unresolved operation in another context references this checkout.');
|
|
463
|
-
else if (stage.input)
|
|
464
|
-
await remove(stage.input, 'duplicate-exports');
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
// Closed peer exports have their own complete ownership proof, independent of project disposal.
|
|
468
|
-
if (projectOwnershipReason) {
|
|
469
|
-
keep(root, projectOwnershipReason);
|
|
470
|
-
continue;
|
|
471
|
-
}
|
|
472
|
-
const given = kind === 'context' && discarded.has(owner);
|
|
473
|
-
const candidates = kind === 'context' ? captured.get(owner) ?? [] : [...(targetCaptures.get(owner) ?? [])];
|
|
474
|
-
if (kind !== 'context')
|
|
475
|
-
try {
|
|
476
|
-
const shared = workspace.model(owner).sharedSnapshot;
|
|
477
|
-
if (shared?.kind === 'snapshot')
|
|
478
|
-
candidates.push(shared);
|
|
479
|
-
}
|
|
480
|
-
catch { /* Unknown model roots cannot supply capture proof. */ }
|
|
481
|
-
if (!nativeRoot && ((worker?.program !== 'program' && worker?.program !== '/program') || typeof worker.root !== 'string' || !sameDirectory(worker.root, root) || !given && !await detachedCapture(workspace, root, candidates))) {
|
|
482
|
-
keep(root, 'Project has no verified full detached program capture; native JSON receipts do not contain program bytes.');
|
|
483
|
-
continue;
|
|
484
|
-
}
|
|
485
|
-
let cleanupComplete = true;
|
|
486
|
-
for (const file of await files(join(root, 'ghidra')))
|
|
487
|
-
if (file.endsWith('.cache'))
|
|
488
|
-
cleanupComplete = await remove(join(root, 'ghidra', file), 'temporary-caches') && cleanupComplete;
|
|
489
|
-
if (nativeRoot) {
|
|
490
|
-
// The project itself belongs to its checkout lifecycle, including uncertain creations.
|
|
491
|
-
for (const run of await directories(join(root, 'explicit-exports')))
|
|
492
|
-
await remove(join(root, 'explicit-exports', run, 'program.gzf'), 'duplicate-exports');
|
|
493
|
-
continue;
|
|
494
|
-
}
|
|
495
|
-
for (const file of await files(join(root, 'exports')))
|
|
496
|
-
if (exportName.test(file))
|
|
497
|
-
cleanupComplete = await remove(join(root, 'exports', file), 'duplicate-exports') && cleanupComplete;
|
|
498
|
-
// Facade edits are captured as they complete; a GUI save is captured only by an explicit close.
|
|
499
|
-
const stop = worker && await stopReceipt(root, worker);
|
|
500
|
-
if (!given && (!stop || worker?.mode !== 'headless' && stop.reason !== 'explicit_close')) {
|
|
501
|
-
keep(join(root, 'view.rep'), 'Project has no clean stop receipt that proves capture.');
|
|
502
|
-
continue;
|
|
503
|
-
}
|
|
504
|
-
if (!await soleProgram(root)) {
|
|
505
|
-
keep(join(root, 'view.rep'), 'Project holds additional files.');
|
|
506
|
-
continue;
|
|
507
|
-
}
|
|
508
|
-
const projectFiles = ['view.rep', 'view.gpr', 'view.lock', 'view.lock~'];
|
|
509
|
-
for (const file of projectFiles)
|
|
510
|
-
cleanupComplete = await remove(join(root, file), 'detached-projects') && cleanupComplete;
|
|
511
|
-
// Every recognized removal must succeed before its full capture proof can be forgotten.
|
|
512
|
-
if (cleanupComplete && await remove(join(root, 'saved.gzf'), 'duplicate-exports'))
|
|
513
|
-
disposedDetachedRoots.add(root);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
for (const run of await directories(join(native, 'explicit-exports')))
|
|
518
|
-
await remove(join(native, 'explicit-exports', run, 'program.gzf'), 'duplicate-exports');
|
|
519
|
-
const calls = join(workspace.directory, 'server', 'calls');
|
|
520
|
-
for (const call of await directories(calls))
|
|
521
|
-
for (const file of await files(join(calls, call, 'ghidra')))
|
|
522
|
-
if (file.endsWith('.cache'))
|
|
523
|
-
await remove(join(calls, call, 'ghidra', file), 'temporary-caches');
|
|
524
|
-
// Roots are live rows, unfinished or failed intents, every user-visible result and VT owners.
|
|
525
|
-
const roots = workspace.artifactRoots();
|
|
526
|
-
for (const id of nativeEvidence)
|
|
527
|
-
roots.add(id);
|
|
528
|
-
// Native release above can remove a project and its live context reference in this same pass.
|
|
529
|
-
for (const [id, root] of nativeProjects)
|
|
530
|
-
try {
|
|
531
|
-
if (await present(join(root, 'view.rep')) || await present(join(root, 'view.gpr')))
|
|
532
|
-
roots.add(id);
|
|
533
|
-
}
|
|
534
|
-
catch {
|
|
535
|
-
roots.add(id);
|
|
536
|
-
keep(root, 'Native project inventory could not be verified; its receipt is retained.');
|
|
537
|
-
}
|
|
538
|
-
// Migration journals keep identity, not artifact liveness. A retained saved.gzf still needs its
|
|
539
|
-
// canonical verification copy for the next collection attempt, even after the context migrated.
|
|
540
|
-
for (const kind of ['context', 'shared', 'candidate'])
|
|
541
|
-
for (const owner of await directories(join(native, kind))) {
|
|
542
|
-
const proofs = kind === 'context' ? (discarded.has(owner) ? [] : captured.get(owner) ?? []) : targetCaptures.get(owner) ?? [];
|
|
543
|
-
if (!proofs.length)
|
|
544
|
-
continue;
|
|
545
|
-
for (const name of await directories(join(native, kind, owner))) {
|
|
546
|
-
const root = join(native, kind, owner, name);
|
|
547
|
-
if (disposedDetachedRoots.has(root))
|
|
548
|
-
continue;
|
|
549
|
-
try {
|
|
550
|
-
if (!await present(join(root, 'saved.gzf')))
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
|
-
catch {
|
|
554
|
-
keep(root, 'Retained capture metadata could not be verified; its snapshot proof is preserved.');
|
|
555
|
-
}
|
|
556
|
-
for (const artifact of proofs)
|
|
557
|
-
roots.add(artifact.id);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
for (const tracking of await directories(join(workspace.directory, 'version-tracking'))) {
|
|
561
|
-
let owner = '';
|
|
562
|
-
try {
|
|
563
|
-
owner = await readFile(join(workspace.directory, 'version-tracking', tracking, 'owner.json'), 'utf8');
|
|
564
|
-
}
|
|
565
|
-
catch (error) {
|
|
566
|
-
if (!missing(error))
|
|
567
|
-
throw error;
|
|
568
|
-
}
|
|
569
|
-
for (const match of owner.matchAll(/(?:snapshot|native):[a-f0-9]{64}/g))
|
|
570
|
-
roots.add(match[0]);
|
|
571
|
-
}
|
|
572
|
-
const rows = new Set(workspace.allArtifacts().map(a => a.id));
|
|
573
|
-
if (!dryRun)
|
|
574
|
-
for (const artifact of workspace.allArtifacts())
|
|
575
|
-
if (artifact.kind !== 'input' && !roots.has(artifact.id))
|
|
576
|
-
workspace.forgetArtifact(artifact.id);
|
|
577
|
-
const directory = join(workspace.directory, 'artifacts');
|
|
578
|
-
for (const file of await files(directory)) {
|
|
579
|
-
const match = artifactName.exec(file);
|
|
580
|
-
const id = match && (match[2] === 'gzf' ? 'snapshot:' : 'native:') + match[1];
|
|
581
|
-
// A capture writes its file before its row, so unrowed files are stale only after a day.
|
|
582
|
-
if (id ? !roots.has(id) && (rows.has(id) || await older(join(directory, file), 86400000)) : pendingName.test(file) && await older(join(directory, file), 86400000))
|
|
583
|
-
await remove(join(directory, file), 'unreferenced-snapshots');
|
|
584
|
-
}
|
|
585
|
-
for (const [category, bytes] of Object.entries(reclaimed.bytes()))
|
|
586
|
-
if (categories[category])
|
|
587
|
-
categories[category].bytes += bytes;
|
|
588
|
-
const result = { state: dryRun ? 'planned' : 'complete', dryRun, bytes: Object.values(categories).reduce((n, c) => n + c.bytes, 0), categories, retainedCount: retained.length };
|
|
589
|
-
if (!dryRun)
|
|
590
|
-
await durable(receipt, { schema: 1, id, startedAt, endedAt: new Date().toISOString(), ...result, retained });
|
|
591
|
-
for (const [category, value] of Object.entries(categories))
|
|
592
|
-
auditEvent('gc.category', { gcId: id, dryRun, category, ...value });
|
|
593
|
-
auditEvent('gc.finished', { gcId: id, ...result, outcome: 'success' });
|
|
594
|
-
return { ...result, ...(dryRun ? {} : { id }), retained: retained.slice(0, 200) };
|
|
595
|
-
}
|
|
596
|
-
catch (error) {
|
|
597
|
-
auditEvent('gc.failed', { gcId: id, dryRun, error, outcome: 'failure' });
|
|
598
|
-
throw error;
|
|
599
|
-
}
|
|
600
|
-
}
|
package/dist/src/store.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type Batch, type Binding, type FindingRecord, type State, type Target } from './model.js';
|
|
2
|
-
export declare class Store {
|
|
3
|
-
readonly directory: string;
|
|
4
|
-
readonly profile: string;
|
|
5
|
-
readonly server: string;
|
|
6
|
-
static pending(directory: string): boolean;
|
|
7
|
-
private db;
|
|
8
|
-
constructor(directory: string, profile: string, server: string);
|
|
9
|
-
close(): void;
|
|
10
|
-
private transaction;
|
|
11
|
-
register(value: unknown): Target;
|
|
12
|
-
target(id: string): Target;
|
|
13
|
-
targets(): Target[];
|
|
14
|
-
submit(value: unknown): FindingRecord;
|
|
15
|
-
getFinding(id: string): FindingRecord;
|
|
16
|
-
findings(targetId?: string): FindingRecord[];
|
|
17
|
-
begin(targetId: string): Batch | undefined;
|
|
18
|
-
batch(id: string): Batch;
|
|
19
|
-
batches(): Batch[];
|
|
20
|
-
update(id: string, state: State, patch?: Partial<Omit<Batch, 'id' | 'targetId' | 'findings'>>): Batch;
|
|
21
|
-
conflicts(id: string, conflicts: unknown): void;
|
|
22
|
-
private event;
|
|
23
|
-
events(id: string): {
|
|
24
|
-
seq: import("node:sqlite").SQLOutputValue | undefined;
|
|
25
|
-
state: import("node:sqlite").SQLOutputValue | undefined;
|
|
26
|
-
data: any;
|
|
27
|
-
}[];
|
|
28
|
-
worker(id: string): Binding;
|
|
29
|
-
putWorker(id: string, targetId: string, binding: Binding): void;
|
|
30
|
-
updateReader(id: string, binding: Binding): void;
|
|
31
|
-
workers(): any[];
|
|
32
|
-
removeWorker(id: string): void;
|
|
33
|
-
}
|