@duckmind/dm-linux-x64 0.66.0 → 0.66.2
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/dm +2 -2
- package/extensions/.dm-extensions.json +12 -546
- package/extensions/dm-lens/clients/dispatch/runners/utils/runner-helpers.js +1 -1
- package/extensions/dm-mcp-adapter/mcp-keyring-helper.cjs +1 -1
- package/extensions/dm-ponytail/hooks/ponytail-activate.js +1 -1
- package/extensions/dm-ponytail/hooks/ponytail-instructions.js +1 -1
- package/extensions/dm-subagents/src/runs/background/runner-aliases.js +2 -2
- package/extensions/dm-subagents/src/runs/foreground/prompt-audit.js +4 -1
- package/extensions/dm-subagents/src/runs/shared/child-session.js +8 -6
- package/extensions/dm-subagents/src/watchdog/permission-arbiter.js +9 -1
- package/extensions/dm-subagents/src/watchdog/review.js +4 -1
- package/package.json +1 -1
- package/extensions/dm-lens/dist/clients/actionable-warnings-logger.js +0 -24
- package/extensions/dm-lens/dist/clients/actionable-warnings.js +0 -1014
- package/extensions/dm-lens/dist/clients/advisory-provenance.js +0 -385
- package/extensions/dm-lens/dist/clients/agent-behavior-client.js +0 -94
- package/extensions/dm-lens/dist/clients/agent-nudge.js +0 -151
- package/extensions/dm-lens/dist/clients/analysed-root.js +0 -1
- package/extensions/dm-lens/dist/clients/ast-grep-client.js +0 -576
- package/extensions/dm-lens/dist/clients/ast-grep-rule-manager.js +0 -114
- package/extensions/dm-lens/dist/clients/ast-grep-tool-logger.js +0 -85
- package/extensions/dm-lens/dist/clients/ast-grep-types.js +0 -1
- package/extensions/dm-lens/dist/clients/ast-grep-yaml-synth.js +0 -109
- package/extensions/dm-lens/dist/clients/atomic-write-staging.js +0 -66
- package/extensions/dm-lens/dist/clients/atomic-write.js +0 -37
- package/extensions/dm-lens/dist/clients/availability-probe-flight.js +0 -11
- package/extensions/dm-lens/dist/clients/bash-file-access.js +0 -830
- package/extensions/dm-lens/dist/clients/biome-client.js +0 -221
- package/extensions/dm-lens/dist/clients/blocker-freshness.js +0 -385
- package/extensions/dm-lens/dist/clients/blocker-past-eof.js +0 -49
- package/extensions/dm-lens/dist/clients/bootstrap.js +0 -246
- package/extensions/dm-lens/dist/clients/bounded-cache.js +0 -105
- package/extensions/dm-lens/dist/clients/bounded-pid-file-lock.js +0 -173
- package/extensions/dm-lens/dist/clients/bounded-telemetry.js +0 -104
- package/extensions/dm-lens/dist/clients/build-identity.js +0 -45
- package/extensions/dm-lens/dist/clients/bundled-resource-health.js +0 -41
- package/extensions/dm-lens/dist/clients/bus-events-logger.js +0 -48
- package/extensions/dm-lens/dist/clients/bus-publish.js +0 -117
- package/extensions/dm-lens/dist/clients/cache/rule-cache.js +0 -103
- package/extensions/dm-lens/dist/clients/cache-manager.js +0 -340
- package/extensions/dm-lens/dist/clients/cache-observability.js +0 -847
- package/extensions/dm-lens/dist/clients/call-graph.js +0 -628
- package/extensions/dm-lens/dist/clients/cargo-manifest.js +0 -151
- package/extensions/dm-lens/dist/clients/cascade-budget.js +0 -52
- package/extensions/dm-lens/dist/clients/cascade-format.js +0 -160
- package/extensions/dm-lens/dist/clients/cascade-logger.js +0 -22
- package/extensions/dm-lens/dist/clients/cascade-types.js +0 -1
- package/extensions/dm-lens/dist/clients/child-unref.js +0 -59
- package/extensions/dm-lens/dist/clients/code-quality-warnings.js +0 -192
- package/extensions/dm-lens/dist/clients/codebase-model.js +0 -110
- package/extensions/dm-lens/dist/clients/collateral-test-role.js +0 -8
- package/extensions/dm-lens/dist/clients/complexity-client.js +0 -398
- package/extensions/dm-lens/dist/clients/config-core/deny.js +0 -117
- package/extensions/dm-lens/dist/clients/config-core/index.js +0 -2
- package/extensions/dm-lens/dist/clients/config-core/merge.js +0 -228
- package/extensions/dm-lens/dist/clients/config-core/normalize.js +0 -217
- package/extensions/dm-lens/dist/clients/config-core/process-spec.js +0 -147
- package/extensions/dm-lens/dist/clients/config-core/provenance.js +0 -54
- package/extensions/dm-lens/dist/clients/config-core/records.js +0 -79
- package/extensions/dm-lens/dist/clients/config-core/resolve.js +0 -48
- package/extensions/dm-lens/dist/clients/config-core/safe-object.js +0 -22
- package/extensions/dm-lens/dist/clients/config-core/schema.js +0 -90
- package/extensions/dm-lens/dist/clients/config-diagnostic-codes.js +0 -90
- package/extensions/dm-lens/dist/clients/config-locations.js +0 -175
- package/extensions/dm-lens/dist/clients/config-resolve.js +0 -359
- package/extensions/dm-lens/dist/clients/config-schema.js +0 -128
- package/extensions/dm-lens/dist/clients/config-warn.js +0 -146
- package/extensions/dm-lens/dist/clients/console-guard-install.js +0 -4
- package/extensions/dm-lens/dist/clients/cooperative-budget.js +0 -36
- package/extensions/dm-lens/dist/clients/dead-code-client.js +0 -342
- package/extensions/dm-lens/dist/clients/dead-code-logger.js +0 -18
- package/extensions/dm-lens/dist/clients/deadline-utils.js +0 -117
- package/extensions/dm-lens/dist/clients/debug-handles.js +0 -121
- package/extensions/dm-lens/dist/clients/debug-heap.js +0 -80
- package/extensions/dm-lens/dist/clients/deferred-lsp-work.js +0 -33
- package/extensions/dm-lens/dist/clients/degradation-ledger.js +0 -272
- package/extensions/dm-lens/dist/clients/demoted-finding-render.js +0 -61
- package/extensions/dm-lens/dist/clients/dependency-checker.js +0 -525
- package/extensions/dm-lens/dist/clients/deps/ast-grep-napi.js +0 -17
- package/extensions/dm-lens/dist/clients/deps/dm-host-deps.js +0 -10
- package/extensions/dm-lens/dist/clients/deps/dm-tui-compat.js +0 -58
- package/extensions/dm-lens/dist/clients/deps/js-yaml.js +0 -7
- package/extensions/dm-lens/dist/clients/deps/minimatch.js +0 -6
- package/extensions/dm-lens/dist/clients/deps/pidusage.js +0 -5
- package/extensions/dm-lens/dist/clients/deps/typebox.js +0 -5
- package/extensions/dm-lens/dist/clients/deps/vscode-jsonrpc.js +0 -8
- package/extensions/dm-lens/dist/clients/deps/web-tree-sitter.js +0 -11
- package/extensions/dm-lens/dist/clients/diagnostic-dispositions.js +0 -318
- package/extensions/dm-lens/dist/clients/diagnostic-line-freshness.js +0 -144
- package/extensions/dm-lens/dist/clients/diagnostic-logger.js +0 -60
- package/extensions/dm-lens/dist/clients/diagnostic-tracker.js +0 -89
- package/extensions/dm-lens/dist/clients/diagnostics-publish.js +0 -134
- package/extensions/dm-lens/dist/clients/dispatch/ast-grep-catalog.js +0 -16
- package/extensions/dm-lens/dist/clients/dispatch/auxiliary-lsp.js +0 -158
- package/extensions/dm-lens/dist/clients/dispatch/collect-later-tier.js +0 -25
- package/extensions/dm-lens/dist/clients/dispatch/diagnostic-taxonomy.js +0 -58
- package/extensions/dm-lens/dist/clients/dispatch/dispatcher.js +0 -953
- package/extensions/dm-lens/dist/clients/dispatch/fact-provider-types.js +0 -1
- package/extensions/dm-lens/dist/clients/dispatch/fact-rule-runner.js +0 -17
- package/extensions/dm-lens/dist/clients/dispatch/fact-runner.js +0 -18
- package/extensions/dm-lens/dist/clients/dispatch/fact-scheduler.js +0 -52
- package/extensions/dm-lens/dist/clients/dispatch/fact-store.js +0 -199
- package/extensions/dm-lens/dist/clients/dispatch/facts/comment-facts.js +0 -20
- package/extensions/dm-lens/dist/clients/dispatch/facts/file-content.js +0 -18
- package/extensions/dm-lens/dist/clients/dispatch/facts/function-facts.js +0 -281
- package/extensions/dm-lens/dist/clients/dispatch/facts/import-facts.js +0 -169
- package/extensions/dm-lens/dist/clients/dispatch/facts/tree-sitter-facts.js +0 -19
- package/extensions/dm-lens/dist/clients/dispatch/facts/try-catch-facts.js +0 -95
- package/extensions/dm-lens/dist/clients/dispatch/finding-policy.js +0 -159
- package/extensions/dm-lens/dist/clients/dispatch/indent-detect.js +0 -227
- package/extensions/dm-lens/dist/clients/dispatch/inline-suppressions.js +0 -52
- package/extensions/dm-lens/dist/clients/dispatch/integration.js +0 -1463
- package/extensions/dm-lens/dist/clients/dispatch/lazy.js +0 -8
- package/extensions/dm-lens/dist/clients/dispatch/pending-runner-findings.js +0 -75
- package/extensions/dm-lens/dist/clients/dispatch/plan.js +0 -278
- package/extensions/dm-lens/dist/clients/dispatch/priorities.js +0 -14
- package/extensions/dm-lens/dist/clients/dispatch/rule-id-normalize.js +0 -42
- package/extensions/dm-lens/dist/clients/dispatch/rule-ignores.js +0 -21
- package/extensions/dm-lens/dist/clients/dispatch/rule-policy.js +0 -73
- package/extensions/dm-lens/dist/clients/dispatch/rules/async-noise.js +0 -31
- package/extensions/dm-lens/dist/clients/dispatch/rules/async-unnecessary-wrapper.js +0 -27
- package/extensions/dm-lens/dist/clients/dispatch/rules/cors-wildcard.js +0 -35
- package/extensions/dm-lens/dist/clients/dispatch/rules/error-obscuring.js +0 -29
- package/extensions/dm-lens/dist/clients/dispatch/rules/error-swallowing.js +0 -29
- package/extensions/dm-lens/dist/clients/dispatch/rules/framework-call-noise.js +0 -31
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-complexity.js +0 -56
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-fan-out.js +0 -45
- package/extensions/dm-lens/dist/clients/dispatch/rules/high-import-coupling.js +0 -31
- package/extensions/dm-lens/dist/clients/dispatch/rules/missing-error-propagation.js +0 -45
- package/extensions/dm-lens/dist/clients/dispatch/rules/no-commented-credentials.js +0 -46
- package/extensions/dm-lens/dist/clients/dispatch/rules/pass-through-wrappers.js +0 -38
- package/extensions/dm-lens/dist/clients/dispatch/rules/placeholder-comments.js +0 -40
- package/extensions/dm-lens/dist/clients/dispatch/rules/unsafe-boundary.js +0 -101
- package/extensions/dm-lens/dist/clients/dispatch/runner-context.js +0 -46
- package/extensions/dm-lens/dist/clients/dispatch/runners/actionlint.js +0 -98
- package/extensions/dm-lens/dist/clients/dispatch/runners/ast-grep-napi.js +0 -690
- package/extensions/dm-lens/dist/clients/dispatch/runners/biome-check.js +0 -202
- package/extensions/dm-lens/dist/clients/dispatch/runners/cpp-check.js +0 -190
- package/extensions/dm-lens/dist/clients/dispatch/runners/credo.js +0 -66
- package/extensions/dm-lens/dist/clients/dispatch/runners/cue-vet.js +0 -167
- package/extensions/dm-lens/dist/clients/dispatch/runners/dart-analyze.js +0 -151
- package/extensions/dm-lens/dist/clients/dispatch/runners/detekt.js +0 -157
- package/extensions/dm-lens/dist/clients/dispatch/runners/dotnet-build.js +0 -157
- package/extensions/dm-lens/dist/clients/dispatch/runners/elixir-check.js +0 -153
- package/extensions/dm-lens/dist/clients/dispatch/runners/eslint.js +0 -99
- package/extensions/dm-lens/dist/clients/dispatch/runners/fact-rules.js +0 -20
- package/extensions/dm-lens/dist/clients/dispatch/runners/fish-indent.js +0 -65
- package/extensions/dm-lens/dist/clients/dispatch/runners/gleam-check.js +0 -107
- package/extensions/dm-lens/dist/clients/dispatch/runners/go-vet.js +0 -51
- package/extensions/dm-lens/dist/clients/dispatch/runners/golangci-lint.js +0 -89
- package/extensions/dm-lens/dist/clients/dispatch/runners/hadolint.js +0 -83
- package/extensions/dm-lens/dist/clients/dispatch/runners/helm-lint.js +0 -144
- package/extensions/dm-lens/dist/clients/dispatch/runners/helm-render.js +0 -593
- package/extensions/dm-lens/dist/clients/dispatch/runners/htmlhint.js +0 -103
- package/extensions/dm-lens/dist/clients/dispatch/runners/index.js +0 -100
- package/extensions/dm-lens/dist/clients/dispatch/runners/javac.js +0 -82
- package/extensions/dm-lens/dist/clients/dispatch/runners/ktlint.js +0 -93
- package/extensions/dm-lens/dist/clients/dispatch/runners/lsp.js +0 -206
- package/extensions/dm-lens/dist/clients/dispatch/runners/markdownlint.js +0 -129
- package/extensions/dm-lens/dist/clients/dispatch/runners/mypy.js +0 -70
- package/extensions/dm-lens/dist/clients/dispatch/runners/oxlint.js +0 -305
- package/extensions/dm-lens/dist/clients/dispatch/runners/php-lint.js +0 -70
- package/extensions/dm-lens/dist/clients/dispatch/runners/phpstan.js +0 -90
- package/extensions/dm-lens/dist/clients/dispatch/runners/prisma-validate.js +0 -56
- package/extensions/dm-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +0 -307
- package/extensions/dm-lens/dist/clients/dispatch/runners/pyright.js +0 -118
- package/extensions/dm-lens/dist/clients/dispatch/runners/rubocop.js +0 -79
- package/extensions/dm-lens/dist/clients/dispatch/runners/ruff.js +0 -69
- package/extensions/dm-lens/dist/clients/dispatch/runners/rust-clippy.js +0 -147
- package/extensions/dm-lens/dist/clients/dispatch/runners/shellcheck.js +0 -111
- package/extensions/dm-lens/dist/clients/dispatch/runners/shfmt.js +0 -81
- package/extensions/dm-lens/dist/clients/dispatch/runners/spellcheck.js +0 -74
- package/extensions/dm-lens/dist/clients/dispatch/runners/spotbugs.js +0 -208
- package/extensions/dm-lens/dist/clients/dispatch/runners/sqlfluff.js +0 -136
- package/extensions/dm-lens/dist/clients/dispatch/runners/stylelint.js +0 -118
- package/extensions/dm-lens/dist/clients/dispatch/runners/swiftlint.js +0 -143
- package/extensions/dm-lens/dist/clients/dispatch/runners/taplo.js +0 -97
- package/extensions/dm-lens/dist/clients/dispatch/runners/terragrunt.js +0 -110
- package/extensions/dm-lens/dist/clients/dispatch/runners/tflint.js +0 -104
- package/extensions/dm-lens/dist/clients/dispatch/runners/tree-sitter.js +0 -516
- package/extensions/dm-lens/dist/clients/dispatch/runners/trivy-config.js +0 -155
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/availability-policy.js +0 -285
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/candidate-probe.js +0 -61
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -61
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/lazy-installer.js +0 -130
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +0 -1067
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +0 -40
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/tool-failure.js +0 -117
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +0 -88
- package/extensions/dm-lens/dist/clients/dispatch/runners/utils.js +0 -8
- package/extensions/dm-lens/dist/clients/dispatch/runners/vale.js +0 -106
- package/extensions/dm-lens/dist/clients/dispatch/runners/yaml-rule-parser.js +0 -163
- package/extensions/dm-lens/dist/clients/dispatch/runners/yamllint.js +0 -83
- package/extensions/dm-lens/dist/clients/dispatch/runners/zig-check.js +0 -72
- package/extensions/dm-lens/dist/clients/dispatch/suppress-writer.js +0 -57
- package/extensions/dm-lens/dist/clients/dispatch/tool-profile.js +0 -30
- package/extensions/dm-lens/dist/clients/dispatch/types.js +0 -7
- package/extensions/dm-lens/dist/clients/dispatch/utils/format-utils.js +0 -45
- package/extensions/dm-lens/dist/clients/dispatch/utils/lsp-diagnostics.js +0 -31
- package/extensions/dm-lens/dist/clients/disposition-logger.js +0 -19
- package/extensions/dm-lens/dist/clients/disposition-publish.js +0 -88
- package/extensions/dm-lens/dist/clients/durable-store.js +0 -77
- package/extensions/dm-lens/dist/clients/effective-config.js +0 -160
- package/extensions/dm-lens/dist/clients/env-utils.js +0 -26
- package/extensions/dm-lens/dist/clients/error-class.js +0 -3
- package/extensions/dm-lens/dist/clients/eval-timestamp.js +0 -2
- package/extensions/dm-lens/dist/clients/event-loop-hold.js +0 -119
- package/extensions/dm-lens/dist/clients/event-loop-monitor.js +0 -84
- package/extensions/dm-lens/dist/clients/extension-log.js +0 -230
- package/extensions/dm-lens/dist/clients/extension-mode.js +0 -20
- package/extensions/dm-lens/dist/clients/feature-hints.js +0 -88
- package/extensions/dm-lens/dist/clients/file-kinds.js +0 -304
- package/extensions/dm-lens/dist/clients/file-role.js +0 -50
- package/extensions/dm-lens/dist/clients/file-time.js +0 -112
- package/extensions/dm-lens/dist/clients/file-utils.js +0 -630
- package/extensions/dm-lens/dist/clients/finding-delivery-gate.js +0 -129
- package/extensions/dm-lens/dist/clients/finding-identity.js +0 -23
- package/extensions/dm-lens/dist/clients/fix-worklog.js +0 -75
- package/extensions/dm-lens/dist/clients/format-events-publish.js +0 -230
- package/extensions/dm-lens/dist/clients/format-service.js +0 -154
- package/extensions/dm-lens/dist/clients/formatters-lazy.js +0 -8
- package/extensions/dm-lens/dist/clients/formatters.js +0 -1351
- package/extensions/dm-lens/dist/clients/freshness-cadence.js +0 -1
- package/extensions/dm-lens/dist/clients/freshness.js +0 -8
- package/extensions/dm-lens/dist/clients/generated-artifacts.js +0 -209
- package/extensions/dm-lens/dist/clients/generation-guard.js +0 -105
- package/extensions/dm-lens/dist/clients/git-guard.js +0 -770
- package/extensions/dm-lens/dist/clients/git-tracked-ignore.js +0 -120
- package/extensions/dm-lens/dist/clients/gitleaks-client.js +0 -282
- package/extensions/dm-lens/dist/clients/go-client.js +0 -47
- package/extensions/dm-lens/dist/clients/govulncheck-client.js +0 -411
- package/extensions/dm-lens/dist/clients/gradle-ktfmt-style.js +0 -177
- package/extensions/dm-lens/dist/clients/grammar-source.js +0 -224
- package/extensions/dm-lens/dist/clients/gzip-stage-write.js +0 -85
- package/extensions/dm-lens/dist/clients/hashline-anchor.js +0 -222
- package/extensions/dm-lens/dist/clients/hook-budgets.js +0 -16
- package/extensions/dm-lens/dist/clients/host-edit-normalize.js +0 -87
- package/extensions/dm-lens/dist/clients/host-ports.js +0 -35
- package/extensions/dm-lens/dist/clients/indent-retarget.js +0 -102
- package/extensions/dm-lens/dist/clients/inline-blocker-dispositions.js +0 -103
- package/extensions/dm-lens/dist/clients/install-diagnostics.js +0 -123
- package/extensions/dm-lens/dist/clients/installer/index.js +0 -3770
- package/extensions/dm-lens/dist/clients/installer/managed-tool-refresh-session.js +0 -17
- package/extensions/dm-lens/dist/clients/installer/managed-tool-refresh.js +0 -522
- package/extensions/dm-lens/dist/clients/instance-reaper-state.js +0 -3
- package/extensions/dm-lens/dist/clients/instance-reaper.js +0 -577
- package/extensions/dm-lens/dist/clients/instance-registry-lock.js +0 -131
- package/extensions/dm-lens/dist/clients/instance-registry.js +0 -452
- package/extensions/dm-lens/dist/clients/jscpd-client.js +0 -252
- package/extensions/dm-lens/dist/clients/json-cache-read.js +0 -25
- package/extensions/dm-lens/dist/clients/knip-client.js +0 -472
- package/extensions/dm-lens/dist/clients/language-policy.js +0 -242
- package/extensions/dm-lens/dist/clients/language-profile.js +0 -261
- package/extensions/dm-lens/dist/clients/language-registry.js +0 -424
- package/extensions/dm-lens/dist/clients/latency-logger.js +0 -192
- package/extensions/dm-lens/dist/clients/lazy-import.js +0 -14
- package/extensions/dm-lens/dist/clients/ledger-bounds.js +0 -21
- package/extensions/dm-lens/dist/clients/lens-config.js +0 -237
- package/extensions/dm-lens/dist/clients/lens-engine.js +0 -181
- package/extensions/dm-lens/dist/clients/lens-events.js +0 -105
- package/extensions/dm-lens/dist/clients/lens-flag-registry.js +0 -302
- package/extensions/dm-lens/dist/clients/lens-map.js +0 -980
- package/extensions/dm-lens/dist/clients/live-bus-emitter.js +0 -53
- package/extensions/dm-lens/dist/clients/log-cleanup.js +0 -138
- package/extensions/dm-lens/dist/clients/lsp/aggregation.js +0 -88
- package/extensions/dm-lens/dist/clients/lsp/cascade-tier.js +0 -203
- package/extensions/dm-lens/dist/clients/lsp/client.js +0 -2709
- package/extensions/dm-lens/dist/clients/lsp/config.js +0 -252
- package/extensions/dm-lens/dist/clients/lsp/content-limits.js +0 -21
- package/extensions/dm-lens/dist/clients/lsp/diagnostic-binding.js +0 -79
- package/extensions/dm-lens/dist/clients/lsp/document-drift.js +0 -312
- package/extensions/dm-lens/dist/clients/lsp/edits.js +0 -930
- package/extensions/dm-lens/dist/clients/lsp/index.js +0 -4448
- package/extensions/dm-lens/dist/clients/lsp/inferred-project.js +0 -121
- package/extensions/dm-lens/dist/clients/lsp/jvm-runtime.js +0 -194
- package/extensions/dm-lens/dist/clients/lsp/language.js +0 -23
- package/extensions/dm-lens/dist/clients/lsp/launch.js +0 -468
- package/extensions/dm-lens/dist/clients/lsp/lombok.js +0 -146
- package/extensions/dm-lens/dist/clients/lsp/path-utils.js +0 -1
- package/extensions/dm-lens/dist/clients/lsp/pending-aux-coverage.js +0 -90
- package/extensions/dm-lens/dist/clients/lsp/position-encoding.js +0 -28
- package/extensions/dm-lens/dist/clients/lsp/ruby-drive-dirs.js +0 -42
- package/extensions/dm-lens/dist/clients/lsp/server.js +0 -2422
- package/extensions/dm-lens/dist/clients/lsp/session-roots.js +0 -52
- package/extensions/dm-lens/dist/clients/lsp/spawn-history.js +0 -15
- package/extensions/dm-lens/dist/clients/lsp/sync-kind.js +0 -30
- package/extensions/dm-lens/dist/clients/lsp/tsserver-sync.js +0 -156
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/capability-snapshot.js +0 -1
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/classification.js +0 -36
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/index.js +0 -3
- package/extensions/dm-lens/dist/clients/lsp/wait-policy/strategies.js +0 -175
- package/extensions/dm-lens/dist/clients/lsp/watch-queue.js +0 -40
- package/extensions/dm-lens/dist/clients/lsp/workspace-diagnostics-cache.js +0 -267
- package/extensions/dm-lens/dist/clients/lsp/workspace-diagnostics-session.js +0 -7
- package/extensions/dm-lens/dist/clients/lsp/workspace-sweep-hold.js +0 -93
- package/extensions/dm-lens/dist/clients/lsp-budget.js +0 -83
- package/extensions/dm-lens/dist/clients/lsp-document-symbols.js +0 -93
- package/extensions/dm-lens/dist/clients/lsp-lazy.js +0 -8
- package/extensions/dm-lens/dist/clients/lsp-mutation.js +0 -273
- package/extensions/dm-lens/dist/clients/lsp-status.js +0 -37
- package/extensions/dm-lens/dist/clients/map-with-concurrency.js +0 -20
- package/extensions/dm-lens/dist/clients/mcp/analyze.js +0 -251
- package/extensions/dm-lens/dist/clients/mcp/host-shim.js +0 -14
- package/extensions/dm-lens/dist/clients/mcp/ipc.js +0 -302
- package/extensions/dm-lens/dist/clients/mcp/review.js +0 -137
- package/extensions/dm-lens/dist/clients/mcp/session.js +0 -305
- package/extensions/dm-lens/dist/clients/memory-sampler.js +0 -107
- package/extensions/dm-lens/dist/clients/message-end-attribution.js +0 -18
- package/extensions/dm-lens/dist/clients/metrics-client.js +0 -80
- package/extensions/dm-lens/dist/clients/metrics-history.js +0 -255
- package/extensions/dm-lens/dist/clients/middle-man-analysis.js +0 -161
- package/extensions/dm-lens/dist/clients/model-provider.js +0 -31
- package/extensions/dm-lens/dist/clients/module-report-lsp.js +0 -140
- package/extensions/dm-lens/dist/clients/module-report.js +0 -1642
- package/extensions/dm-lens/dist/clients/mutating-tool.js +0 -377
- package/extensions/dm-lens/dist/clients/mutation-attribution.js +0 -168
- package/extensions/dm-lens/dist/clients/mutation-bridge.js +0 -102
- package/extensions/dm-lens/dist/clients/ndjson-logger.js +0 -471
- package/extensions/dm-lens/dist/clients/observed-mutation-sources.js +0 -43
- package/extensions/dm-lens/dist/clients/observed-mutation.js +0 -709
- package/extensions/dm-lens/dist/clients/oldtext-autopatch.js +0 -100
- package/extensions/dm-lens/dist/clients/opaque-mutation-scan.js +0 -313
- package/extensions/dm-lens/dist/clients/opengrep-client.js +0 -216
- package/extensions/dm-lens/dist/clients/opengrep-config.js +0 -52
- package/extensions/dm-lens/dist/clients/package-manager.js +0 -303
- package/extensions/dm-lens/dist/clients/package-root.js +0 -25
- package/extensions/dm-lens/dist/clients/partial-edit-apply.js +0 -337
- package/extensions/dm-lens/dist/clients/path-attribution-telemetry.js +0 -31
- package/extensions/dm-lens/dist/clients/path-keyed-map.js +0 -57
- package/extensions/dm-lens/dist/clients/path-utils.js +0 -476
- package/extensions/dm-lens/dist/clients/performance-report.js +0 -291
- package/extensions/dm-lens/dist/clients/persist-debounce.js +0 -37
- package/extensions/dm-lens/dist/clients/persistent-reverify.js +0 -165
- package/extensions/dm-lens/dist/clients/php-cs-fixer-config.js +0 -15
- package/extensions/dm-lens/dist/clients/pipeline.js +0 -1091
- package/extensions/dm-lens/dist/clients/post-autofix-notice.js +0 -19
- package/extensions/dm-lens/dist/clients/print-mode.js +0 -3
- package/extensions/dm-lens/dist/clients/probe-home-state.js +0 -62
- package/extensions/dm-lens/dist/clients/process-bridge.js +0 -20
- package/extensions/dm-lens/dist/clients/process-singletons.js +0 -69
- package/extensions/dm-lens/dist/clients/process-snapshot.js +0 -22
- package/extensions/dm-lens/dist/clients/project-changes.js +0 -112
- package/extensions/dm-lens/dist/clients/project-conventions.js +0 -152
- package/extensions/dm-lens/dist/clients/project-diagnostics/cache.js +0 -91
- package/extensions/dm-lens/dist/clients/project-diagnostics/extractors.js +0 -53
- package/extensions/dm-lens/dist/clients/project-diagnostics/fresh-fetch.js +0 -408
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +0 -64
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/dead-code.js +0 -38
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/gitleaks.js +0 -21
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/govulncheck.js +0 -23
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/jscpd.js +0 -28
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/knip.js +0 -45
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/madge.js +0 -34
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/opengrep.js +0 -32
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +0 -79
- package/extensions/dm-lens/dist/clients/project-diagnostics/runner-adapters/trivy.js +0 -41
- package/extensions/dm-lens/dist/clients/project-diagnostics/scanner.js +0 -349
- package/extensions/dm-lens/dist/clients/project-diagnostics/types.js +0 -1
- package/extensions/dm-lens/dist/clients/project-lens-config.js +0 -437
- package/extensions/dm-lens/dist/clients/project-report.js +0 -527
- package/extensions/dm-lens/dist/clients/project-scale.js +0 -60
- package/extensions/dm-lens/dist/clients/project-scan-policy.js +0 -4
- package/extensions/dm-lens/dist/clients/project-snapshot-fingerprint.js +0 -39
- package/extensions/dm-lens/dist/clients/project-snapshot-persist-worker.js +0 -14
- package/extensions/dm-lens/dist/clients/project-snapshot.js +0 -1178
- package/extensions/dm-lens/dist/clients/project-trust.js +0 -104
- package/extensions/dm-lens/dist/clients/python-environment.js +0 -120
- package/extensions/dm-lens/dist/clients/python-provenance.js +0 -551
- package/extensions/dm-lens/dist/clients/quiet-window-config.js +0 -16
- package/extensions/dm-lens/dist/clients/quiet-window.js +0 -126
- package/extensions/dm-lens/dist/clients/read-bridge.js +0 -46
- package/extensions/dm-lens/dist/clients/read-expansion.js +0 -218
- package/extensions/dm-lens/dist/clients/read-guard-logger.js +0 -178
- package/extensions/dm-lens/dist/clients/read-guard-tool-lines.js +0 -1042
- package/extensions/dm-lens/dist/clients/read-guard.js +0 -1096
- package/extensions/dm-lens/dist/clients/recent-touches.js +0 -126
- package/extensions/dm-lens/dist/clients/redact/secrets.js +0 -386
- package/extensions/dm-lens/dist/clients/resource-sampler.js +0 -344
- package/extensions/dm-lens/dist/clients/reverse-deps.js +0 -227
- package/extensions/dm-lens/dist/clients/review-graph/builder.js +0 -3635
- package/extensions/dm-lens/dist/clients/review-graph/format.js +0 -30
- package/extensions/dm-lens/dist/clients/review-graph/git-identity.js +0 -115
- package/extensions/dm-lens/dist/clients/review-graph/import-resolvers.js +0 -325
- package/extensions/dm-lens/dist/clients/review-graph/persist-worker.js +0 -8
- package/extensions/dm-lens/dist/clients/review-graph/query.js +0 -195
- package/extensions/dm-lens/dist/clients/review-graph/revision-drift.js +0 -3
- package/extensions/dm-lens/dist/clients/review-graph/service.js +0 -60
- package/extensions/dm-lens/dist/clients/review-graph/shared-extraction-ir.js +0 -54
- package/extensions/dm-lens/dist/clients/review-graph/symbol-id.js +0 -29
- package/extensions/dm-lens/dist/clients/review-graph/tsconfig-paths.js +0 -253
- package/extensions/dm-lens/dist/clients/review-graph/types.js +0 -1
- package/extensions/dm-lens/dist/clients/review-graph/workspace-modules.js +0 -374
- package/extensions/dm-lens/dist/clients/review-graph-logger.js +0 -51
- package/extensions/dm-lens/dist/clients/ruff-client.js +0 -109
- package/extensions/dm-lens/dist/clients/rules-scanner.js +0 -113
- package/extensions/dm-lens/dist/clients/run-duration.js +0 -9
- package/extensions/dm-lens/dist/clients/runtime-agent-end.js +0 -608
- package/extensions/dm-lens/dist/clients/runtime-config.js +0 -39
- package/extensions/dm-lens/dist/clients/runtime-context.js +0 -155
- package/extensions/dm-lens/dist/clients/runtime-coordinator.js +0 -817
- package/extensions/dm-lens/dist/clients/runtime-session.js +0 -1625
- package/extensions/dm-lens/dist/clients/runtime-tool-call.js +0 -868
- package/extensions/dm-lens/dist/clients/runtime-tool-result.js +0 -1317
- package/extensions/dm-lens/dist/clients/runtime-turn.js +0 -2333
- package/extensions/dm-lens/dist/clients/rust-client.js +0 -48
- package/extensions/dm-lens/dist/clients/safe-spawn.js +0 -1267
- package/extensions/dm-lens/dist/clients/sanitize.js +0 -174
- package/extensions/dm-lens/dist/clients/scan-utils.js +0 -7
- package/extensions/dm-lens/dist/clients/scratch-tree-policy.js +0 -57
- package/extensions/dm-lens/dist/clients/search-read-registration.js +0 -59
- package/extensions/dm-lens/dist/clients/secret-findings.js +0 -69
- package/extensions/dm-lens/dist/clients/security-scan-client.js +0 -208
- package/extensions/dm-lens/dist/clients/session-event-guard.js +0 -111
- package/extensions/dm-lens/dist/clients/session-lifecycle.js +0 -173
- package/extensions/dm-lens/dist/clients/session-start-observability.js +0 -47
- package/extensions/dm-lens/dist/clients/session-state-store.js +0 -63
- package/extensions/dm-lens/dist/clients/session-summary.js +0 -8
- package/extensions/dm-lens/dist/clients/sessionstart-logger.js +0 -22
- package/extensions/dm-lens/dist/clients/sg-runner.js +0 -627
- package/extensions/dm-lens/dist/clients/sgconfig.js +0 -280
- package/extensions/dm-lens/dist/clients/shared-checkout-guard.js +0 -177
- package/extensions/dm-lens/dist/clients/single-flight.js +0 -52
- package/extensions/dm-lens/dist/clients/situational-tool-telemetry.js +0 -85
- package/extensions/dm-lens/dist/clients/skills-resolver.js +0 -38
- package/extensions/dm-lens/dist/clients/slow-fs.js +0 -77
- package/extensions/dm-lens/dist/clients/smells-rollup.js +0 -118
- package/extensions/dm-lens/dist/clients/source-filter.js +0 -320
- package/extensions/dm-lens/dist/clients/source-walker.js +0 -96
- package/extensions/dm-lens/dist/clients/spawn-output-cap.js +0 -35
- package/extensions/dm-lens/dist/clients/spawn-timeout-cooldown.js +0 -51
- package/extensions/dm-lens/dist/clients/stale-marker.js +0 -1
- package/extensions/dm-lens/dist/clients/startup-scan.js +0 -222
- package/extensions/dm-lens/dist/clients/startup-timing.js +0 -67
- package/extensions/dm-lens/dist/clients/string-utils.js +0 -6
- package/extensions/dm-lens/dist/clients/subagent-mode.js +0 -40
- package/extensions/dm-lens/dist/clients/symbol-containment.js +0 -16
- package/extensions/dm-lens/dist/clients/symbol-types.js +0 -1
- package/extensions/dm-lens/dist/clients/test-runner-client.js +0 -1504
- package/extensions/dm-lens/dist/clients/test-runner-delivery.js +0 -260
- package/extensions/dm-lens/dist/clients/todo-scanner.js +0 -164
- package/extensions/dm-lens/dist/clients/tool-agreement.js +0 -377
- package/extensions/dm-lens/dist/clients/tool-config.js +0 -218
- package/extensions/dm-lens/dist/clients/tool-cwd.js +0 -235
- package/extensions/dm-lens/dist/clients/tool-definition.js +0 -22
- package/extensions/dm-lens/dist/clients/tool-event.js +0 -18
- package/extensions/dm-lens/dist/clients/tool-policy.js +0 -2393
- package/extensions/dm-lens/dist/clients/tool-probe.js +0 -5
- package/extensions/dm-lens/dist/clients/tool-render.js +0 -79
- package/extensions/dm-lens/dist/clients/tool-set-policy.js +0 -70
- package/extensions/dm-lens/dist/clients/tree-sitter-cache.js +0 -206
- package/extensions/dm-lens/dist/clients/tree-sitter-client.js +0 -2787
- package/extensions/dm-lens/dist/clients/tree-sitter-logger.js +0 -77
- package/extensions/dm-lens/dist/clients/tree-sitter-navigator.js +0 -198
- package/extensions/dm-lens/dist/clients/tree-sitter-query-loader.js +0 -318
- package/extensions/dm-lens/dist/clients/tree-sitter-shared.js +0 -87
- package/extensions/dm-lens/dist/clients/tree-sitter-symbol-extractor.js +0 -957
- package/extensions/dm-lens/dist/clients/trivy-client.js +0 -305
- package/extensions/dm-lens/dist/clients/tui-fit.js +0 -26
- package/extensions/dm-lens/dist/clients/turn-context.js +0 -48
- package/extensions/dm-lens/dist/clients/turn-end/lane.js +0 -1
- package/extensions/dm-lens/dist/clients/turn-end/lanes/govulncheck.js +0 -54
- package/extensions/dm-lens/dist/clients/turn-end/lanes/secrets.js +0 -131
- package/extensions/dm-lens/dist/clients/turn-summary-render.js +0 -56
- package/extensions/dm-lens/dist/clients/turn-summary.js +0 -84
- package/extensions/dm-lens/dist/clients/typos-config.js +0 -9
- package/extensions/dm-lens/dist/clients/user-notify.js +0 -15
- package/extensions/dm-lens/dist/clients/vanished-instance-marker.js +0 -18
- package/extensions/dm-lens/dist/clients/warm-attach.js +0 -210
- package/extensions/dm-lens/dist/clients/widget-state.js +0 -963
- package/extensions/dm-lens/dist/clients/word-index-logger.js +0 -21
- package/extensions/dm-lens/dist/clients/word-index-store.js +0 -222
- package/extensions/dm-lens/dist/clients/word-index.js +0 -1426
- package/extensions/dm-lens/dist/clients/workspace-topology.js +0 -261
- package/extensions/dm-lens/dist/clients/write-ordering-guard.js +0 -24
- package/extensions/dm-lens/dist/clients/zizmor-config.js +0 -160
- package/extensions/dm-lens/dist/i18n.js +0 -67
- package/extensions/dm-lens/dist/index.js +0 -1782
- package/extensions/dm-lens/dist/mcp/analyze-cli.js +0 -178
- package/extensions/dm-lens/dist/mcp/build-staleness.js +0 -55
- package/extensions/dm-lens/dist/mcp/cli.js +0 -78
- package/extensions/dm-lens/dist/mcp/server.js +0 -1208
- package/extensions/dm-lens/dist/mcp/worker.js +0 -33
- package/extensions/dm-lens/dist/scripts/lib/process-scan.mjs +0 -256
- package/extensions/dm-lens/dist/scripts/lib/skills-predicate.mjs +0 -53
- package/extensions/dm-lens/dist/scripts/lib/web-tree-sitter-dir.mjs +0 -45
- package/extensions/dm-lens/dist/tools/activate-tools.js +0 -61
- package/extensions/dm-lens/dist/tools/ast-grep-outline.js +0 -127
- package/extensions/dm-lens/dist/tools/ast-grep-replace.js +0 -226
- package/extensions/dm-lens/dist/tools/ast-grep-search.js +0 -687
- package/extensions/dm-lens/dist/tools/effective-config.js +0 -59
- package/extensions/dm-lens/dist/tools/lens-diagnostic-mark.js +0 -240
- package/extensions/dm-lens/dist/tools/lens-diagnostics.js +0 -1484
- package/extensions/dm-lens/dist/tools/lsp-diagnostics.js +0 -1088
- package/extensions/dm-lens/dist/tools/lsp-navigation.js +0 -1194
- package/extensions/dm-lens/dist/tools/lsp-structured-output.js +0 -277
- package/extensions/dm-lens/dist/tools/module-report.js +0 -332
- package/extensions/dm-lens/dist/tools/project-report.js +0 -72
- package/extensions/dm-lens/dist/tools/render-compact.js +0 -272
- package/extensions/dm-lens/dist/tools/scan-progress.js +0 -31
- package/extensions/dm-lens/dist/tools/shared.js +0 -26
- package/extensions/dm-lens/dist/tools/symbol-search.js +0 -133
- package/extensions/dm-mcp-adapter/dist/abort.js +0 -35
- package/extensions/dm-mcp-adapter/dist/agent-dir.js +0 -45
- package/extensions/dm-mcp-adapter/dist/agent-plugin-loader.js +0 -392
- package/extensions/dm-mcp-adapter/dist/agent-plugin-provenance.js +0 -26
- package/extensions/dm-mcp-adapter/dist/bearer-command-resolver.js +0 -182
- package/extensions/dm-mcp-adapter/dist/claude-plugin-loader.js +0 -350
- package/extensions/dm-mcp-adapter/dist/config.js +0 -1310
- package/extensions/dm-mcp-adapter/dist/consent-manager.js +0 -84
- package/extensions/dm-mcp-adapter/dist/elicitation-handler.js +0 -308
- package/extensions/dm-mcp-adapter/dist/errors.js +0 -225
- package/extensions/dm-mcp-adapter/dist/http-ca.js +0 -71
- package/extensions/dm-mcp-adapter/dist/jev-client.js +0 -359
- package/extensions/dm-mcp-adapter/dist/jev-contracts.js +0 -1
- package/extensions/dm-mcp-adapter/dist/jev-key-store.js +0 -176
- package/extensions/dm-mcp-adapter/dist/json-schema-validator.js +0 -70
- package/extensions/dm-mcp-adapter/dist/lifecycle.js +0 -387
- package/extensions/dm-mcp-adapter/dist/logger.js +0 -115
- package/extensions/dm-mcp-adapter/dist/mcp-auth-fetch.js +0 -86
- package/extensions/dm-mcp-adapter/dist/mcp-auth-flow.js +0 -949
- package/extensions/dm-mcp-adapter/dist/mcp-auth.js +0 -997
- package/extensions/dm-mcp-adapter/dist/mcp-bearer-store.js +0 -182
- package/extensions/dm-mcp-adapter/dist/mcp-callback-server.js +0 -381
- package/extensions/dm-mcp-adapter/dist/mcp-oauth-provider.js +0 -524
- package/extensions/dm-mcp-adapter/dist/mcp-probe.js +0 -151
- package/extensions/dm-mcp-adapter/dist/mcp-tasks.js +0 -300
- package/extensions/dm-mcp-adapter/dist/mcp-trace.js +0 -215
- package/extensions/dm-mcp-adapter/dist/metadata-cache.js +0 -267
- package/extensions/dm-mcp-adapter/dist/npx-resolver.js +0 -465
- package/extensions/dm-mcp-adapter/dist/package-mcp-loader.js +0 -135
- package/extensions/dm-mcp-adapter/dist/request-headers-command.js +0 -294
- package/extensions/dm-mcp-adapter/dist/resource-tools.js +0 -7
- package/extensions/dm-mcp-adapter/dist/runtime-owner.js +0 -94
- package/extensions/dm-mcp-adapter/dist/sampling-handler.js +0 -213
- package/extensions/dm-mcp-adapter/dist/secure-keyring.js +0 -191
- package/extensions/dm-mcp-adapter/dist/server-manager.js +0 -1514
- package/extensions/dm-mcp-adapter/dist/session-approvals.js +0 -127
- package/extensions/dm-mcp-adapter/dist/session-recovery.js +0 -82
- package/extensions/dm-mcp-adapter/dist/state.js +0 -1
- package/extensions/dm-mcp-adapter/dist/types.js +0 -286
- package/extensions/dm-mcp-adapter/dist/ui-app-bridge-helpers.js +0 -36
- package/extensions/dm-mcp-adapter/dist/ui-resource-handler.js +0 -204
- package/extensions/dm-mcp-adapter/dist/ui-stream-types.js +0 -58
- package/extensions/dm-mcp-adapter/dist/ui-tool-visibility.js +0 -26
- package/extensions/dm-mcp-adapter/dist/unix-socket-transport.js +0 -83
- package/extensions/dm-mcp-adapter/dist/utils.js +0 -382
|
@@ -1,1178 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { Worker } from "node:worker_threads";
|
|
5
|
-
import { gunzipSync, gzipSync } from "node:zlib";
|
|
6
|
-
import { writeFileAtomic } from "./atomic-write.js";
|
|
7
|
-
import { BoundedFifoMap } from "./bounded-cache.js";
|
|
8
|
-
import { getProjectDataDir } from "./file-utils.js";
|
|
9
|
-
import { incrementDegradationCount } from "./degradation-ledger.js";
|
|
10
|
-
import { readJsonCache } from "./json-cache-read.js";
|
|
11
|
-
import { logLatency } from "./latency-logger.js";
|
|
12
|
-
import { normalizeMapKey } from "./path-utils.js";
|
|
13
|
-
import { fingerprintProjectSnapshotJson } from "./project-snapshot-fingerprint.js";
|
|
14
|
-
import { detectProjectConventions } from "./project-conventions.js";
|
|
15
|
-
import { deserializeWordIndex, serializeWordIndex } from "./word-index.js";
|
|
16
|
-
export const PROJECT_SNAPSHOT_VERSION = 2;
|
|
17
|
-
function parseSequenceIndex(value) {
|
|
18
|
-
if (!value || typeof value !== "object")
|
|
19
|
-
return;
|
|
20
|
-
const index = value;
|
|
21
|
-
if (typeof index.projectSeq !== "number")
|
|
22
|
-
return;
|
|
23
|
-
if (!Array.isArray(index.fileSeqByPath))
|
|
24
|
-
return;
|
|
25
|
-
const fileSeqByPath = index.fileSeqByPath.filter((entry) => Array.isArray(entry) && typeof entry[0] === "string" && typeof entry[1] === "number");
|
|
26
|
-
return { projectSeq: index.projectSeq, fileSeqByPath };
|
|
27
|
-
}
|
|
28
|
-
export function getProjectSnapshotPath(cwd) {
|
|
29
|
-
return path.join(getProjectDataDir(cwd), "cache", "project-snapshot.json.gz");
|
|
30
|
-
}
|
|
31
|
-
export function getProjectSnapshotLegacyPath(cwd) {
|
|
32
|
-
return path.join(getProjectDataDir(cwd), "cache", "project-snapshot.json");
|
|
33
|
-
}
|
|
34
|
-
export function getProjectSnapshotMetaPath(cwd) {
|
|
35
|
-
return path.join(getProjectDataDir(cwd), "cache", "project-snapshot.meta.json");
|
|
36
|
-
}
|
|
37
|
-
export function isProjectSnapshotFresh(snapshot, currentProjectSeq) {
|
|
38
|
-
return !!snapshot && snapshot.version === PROJECT_SNAPSHOT_VERSION && snapshot.seq === currentProjectSeq;
|
|
39
|
-
}
|
|
40
|
-
function parseSnapshot(value) {
|
|
41
|
-
if (!value || typeof value !== "object")
|
|
42
|
-
return null;
|
|
43
|
-
const snapshot = value;
|
|
44
|
-
if (snapshot.version !== PROJECT_SNAPSHOT_VERSION)
|
|
45
|
-
return null;
|
|
46
|
-
if (typeof snapshot.projectRoot !== "string")
|
|
47
|
-
return null;
|
|
48
|
-
if (typeof snapshot.generatedAt !== "string")
|
|
49
|
-
return null;
|
|
50
|
-
if (typeof snapshot.seq !== "number")
|
|
51
|
-
return null;
|
|
52
|
-
if (!Array.isArray(snapshot.cachedExports))
|
|
53
|
-
return null;
|
|
54
|
-
return {
|
|
55
|
-
version: PROJECT_SNAPSHOT_VERSION,
|
|
56
|
-
projectRoot: snapshot.projectRoot,
|
|
57
|
-
generatedAt: snapshot.generatedAt,
|
|
58
|
-
seq: snapshot.seq,
|
|
59
|
-
files: snapshot.files ?? {},
|
|
60
|
-
symbols: snapshot.symbols ?? {},
|
|
61
|
-
reverseDeps: snapshot.reverseDeps ?? {},
|
|
62
|
-
cachedExports: snapshot.cachedExports.filter((entry) => Array.isArray(entry) && typeof entry[0] === "string" && typeof entry[1] === "string"),
|
|
63
|
-
sequenceIndex: parseSequenceIndex(snapshot.sequenceIndex),
|
|
64
|
-
wordIndex: snapshot.wordIndex,
|
|
65
|
-
projectRulesScan: snapshot.projectRulesScan,
|
|
66
|
-
startupScan: snapshot.startupScan,
|
|
67
|
-
languageProfile: snapshot.languageProfile,
|
|
68
|
-
conventions: snapshot.conventions
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function parseSnapshotMeta(value) {
|
|
72
|
-
if (!value || typeof value !== "object")
|
|
73
|
-
return null;
|
|
74
|
-
const meta = value;
|
|
75
|
-
if (typeof meta.version !== "number")
|
|
76
|
-
return null;
|
|
77
|
-
if (typeof meta.seq !== "number")
|
|
78
|
-
return null;
|
|
79
|
-
return {
|
|
80
|
-
timestamp: typeof meta.timestamp === "string" ? meta.timestamp : "",
|
|
81
|
-
version: meta.version,
|
|
82
|
-
seq: meta.seq,
|
|
83
|
-
fingerprint: typeof meta.fingerprint === "string" && /^[a-f0-9]{64}$/.test(meta.fingerprint) ? meta.fingerprint : undefined,
|
|
84
|
-
gzBytes: typeof meta.gzBytes === "number" && Number.isInteger(meta.gzBytes) && meta.gzBytes > 0 ? meta.gzBytes : undefined,
|
|
85
|
-
sequenceIndex: parseSequenceIndex(meta.sequenceIndex)
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
export function readProjectSnapshotMeta(cwd) {
|
|
89
|
-
const meta = readJsonCache(getProjectSnapshotMetaPath(cwd), (parsed) => parseSnapshotMeta(parsed) ?? undefined);
|
|
90
|
-
return meta ?? null;
|
|
91
|
-
}
|
|
92
|
-
export function isProjectSnapshotMetaStale(meta, currentProjectSeq) {
|
|
93
|
-
return meta.version !== PROJECT_SNAPSHOT_VERSION || meta.seq !== currentProjectSeq;
|
|
94
|
-
}
|
|
95
|
-
export const SNAPSHOT_PARSE_CACHE_MAX = 4;
|
|
96
|
-
const SNAPSHOT_PARSE_CACHE_MAX_BYTES = 24 * 1024 * 1024;
|
|
97
|
-
const snapshotParseCache = new BoundedFifoMap(SNAPSHOT_PARSE_CACHE_MAX);
|
|
98
|
-
function withoutWordIndex(snapshot) {
|
|
99
|
-
if (!snapshot?.wordIndex)
|
|
100
|
-
return snapshot;
|
|
101
|
-
const { wordIndex: _releasedPostings, ...stripped } = snapshot;
|
|
102
|
-
return stripped;
|
|
103
|
-
}
|
|
104
|
-
function cacheParsedSnapshot(snapshotPath, entry) {
|
|
105
|
-
snapshotParseCache.delete(snapshotPath);
|
|
106
|
-
snapshotParseCache.set(snapshotPath, entry);
|
|
107
|
-
}
|
|
108
|
-
const authoritativeSnapshots = new Map;
|
|
109
|
-
export const PROJECT_SNAPSHOT_MAX_WARM_ROOTS = 8;
|
|
110
|
-
const PROJECT_SNAPSHOT_IDLE_EVICT_MS_DEFAULT = 20 * 60000;
|
|
111
|
-
function projectSnapshotIdleEvictMs() {
|
|
112
|
-
const value = Number.parseInt(process.env.DM_LENS_PROJECT_SNAPSHOT_IDLE_EVICT_MS ?? "", 10);
|
|
113
|
-
return Number.isSafeInteger(value) && value > 0 ? value : PROJECT_SNAPSHOT_IDLE_EVICT_MS_DEFAULT;
|
|
114
|
-
}
|
|
115
|
-
function clearAuthoritativeSnapshotTimer(entry) {
|
|
116
|
-
if (entry.idleTimer)
|
|
117
|
-
clearTimeout(entry.idleTimer);
|
|
118
|
-
entry.idleTimer = undefined;
|
|
119
|
-
}
|
|
120
|
-
function deleteAuthoritativeSnapshot(key) {
|
|
121
|
-
const entry = authoritativeSnapshots.get(key);
|
|
122
|
-
if (entry)
|
|
123
|
-
clearAuthoritativeSnapshotTimer(entry);
|
|
124
|
-
authoritativeSnapshots.delete(key);
|
|
125
|
-
}
|
|
126
|
-
function scheduleAuthoritativeSnapshotEviction(key, entry) {
|
|
127
|
-
clearAuthoritativeSnapshotTimer(entry);
|
|
128
|
-
const generation = entry.lastUsedAt;
|
|
129
|
-
entry.idleTimer = setTimeout(() => {
|
|
130
|
-
entry.idleTimer = undefined;
|
|
131
|
-
if (authoritativeSnapshots.get(key) !== entry || entry.lastUsedAt !== generation)
|
|
132
|
-
return;
|
|
133
|
-
deleteAuthoritativeSnapshot(key);
|
|
134
|
-
}, projectSnapshotIdleEvictMs());
|
|
135
|
-
entry.idleTimer.unref?.();
|
|
136
|
-
}
|
|
137
|
-
function touchAuthoritativeSnapshot(key, entry) {
|
|
138
|
-
entry.lastUsedAt = Date.now();
|
|
139
|
-
scheduleAuthoritativeSnapshotEviction(key, entry);
|
|
140
|
-
}
|
|
141
|
-
function enforceAuthoritativeSnapshotCap() {
|
|
142
|
-
while (authoritativeSnapshots.size > PROJECT_SNAPSHOT_MAX_WARM_ROOTS) {
|
|
143
|
-
const victim = [...authoritativeSnapshots.entries()].sort(([, a], [, b]) => a.lastUsedAt - b.lastUsedAt)[0];
|
|
144
|
-
if (!victim)
|
|
145
|
-
return;
|
|
146
|
-
clearAuthoritativeSnapshotTimer(victim[1]);
|
|
147
|
-
deleteAuthoritativeSnapshot(victim[0]);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
export function _getAuthoritativeSnapshotCacheKeysForTests() {
|
|
151
|
-
return [...authoritativeSnapshots.entries()].sort(([, a], [, b]) => a.lastUsedAt - b.lastUsedAt).map(([key]) => key);
|
|
152
|
-
}
|
|
153
|
-
export function _resetProjectSnapshotParseCacheForTests() {
|
|
154
|
-
snapshotParseCache.clear();
|
|
155
|
-
for (const entry of authoritativeSnapshots.values())
|
|
156
|
-
clearAuthoritativeSnapshotTimer(entry);
|
|
157
|
-
authoritativeSnapshots.clear();
|
|
158
|
-
}
|
|
159
|
-
export function _projectSnapshotParseCacheRetainsWordIndexForTests() {
|
|
160
|
-
return [...snapshotParseCache.values()].some((entry) => entry.snapshot?.wordIndex !== undefined);
|
|
161
|
-
}
|
|
162
|
-
function resolveSnapshotBodyPath(cwd) {
|
|
163
|
-
const gzPath = getProjectSnapshotPath(cwd);
|
|
164
|
-
try {
|
|
165
|
-
const stat = fs.statSync(gzPath);
|
|
166
|
-
return { path: gzPath, gz: true, mtimeMs: stat.mtimeMs, size: stat.size };
|
|
167
|
-
} catch {}
|
|
168
|
-
const legacyPath = getProjectSnapshotLegacyPath(cwd);
|
|
169
|
-
try {
|
|
170
|
-
const stat = fs.statSync(legacyPath);
|
|
171
|
-
return {
|
|
172
|
-
path: legacyPath,
|
|
173
|
-
gz: false,
|
|
174
|
-
mtimeMs: stat.mtimeMs,
|
|
175
|
-
size: stat.size
|
|
176
|
-
};
|
|
177
|
-
} catch {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
let _snapshotBodyReadCountForTests = 0;
|
|
182
|
-
export function getSnapshotBodyReadCountForTests() {
|
|
183
|
-
return _snapshotBodyReadCountForTests;
|
|
184
|
-
}
|
|
185
|
-
export function resetSnapshotBodyReadCountForTests() {
|
|
186
|
-
_snapshotBodyReadCountForTests = 0;
|
|
187
|
-
}
|
|
188
|
-
function readSnapshotBody(bodyPath, gz) {
|
|
189
|
-
_snapshotBodyReadCountForTests++;
|
|
190
|
-
if (!gz) {
|
|
191
|
-
const snapshot = readJsonCache(bodyPath, (parsed) => parseSnapshot(parsed) ?? undefined) ?? null;
|
|
192
|
-
let rawBytes = 0;
|
|
193
|
-
try {
|
|
194
|
-
rawBytes = fs.statSync(bodyPath).size;
|
|
195
|
-
} catch {}
|
|
196
|
-
return { snapshot, rawBytes };
|
|
197
|
-
}
|
|
198
|
-
try {
|
|
199
|
-
const json = gunzipSync(fs.readFileSync(bodyPath)).toString("utf-8");
|
|
200
|
-
const snapshot = parseSnapshot(JSON.parse(json)) ?? null;
|
|
201
|
-
return { snapshot, rawBytes: Buffer.byteLength(json) };
|
|
202
|
-
} catch (err) {
|
|
203
|
-
logLatency({
|
|
204
|
-
type: "phase",
|
|
205
|
-
phase: "project_snapshot_body_corrupt",
|
|
206
|
-
filePath: bodyPath,
|
|
207
|
-
durationMs: 0,
|
|
208
|
-
metadata: { error: err instanceof Error ? err.message : String(err) }
|
|
209
|
-
});
|
|
210
|
-
return { snapshot: null, rawBytes: 0 };
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function skipJsonValue(text, start) {
|
|
214
|
-
let i = start;
|
|
215
|
-
while (i < text.length && /\s/.test(text[i]))
|
|
216
|
-
i++;
|
|
217
|
-
const ch = text[i];
|
|
218
|
-
if (ch === '"') {
|
|
219
|
-
i++;
|
|
220
|
-
while (i < text.length) {
|
|
221
|
-
if (text[i] === "\\") {
|
|
222
|
-
i += 2;
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
if (text[i] === '"') {
|
|
226
|
-
i++;
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
i++;
|
|
230
|
-
}
|
|
231
|
-
return i;
|
|
232
|
-
}
|
|
233
|
-
if (ch === "{" || ch === "[") {
|
|
234
|
-
const open = ch;
|
|
235
|
-
const close = open === "{" ? "}" : "]";
|
|
236
|
-
let depth = 0;
|
|
237
|
-
let inString = false;
|
|
238
|
-
for (;i < text.length; i++) {
|
|
239
|
-
const c = text[i];
|
|
240
|
-
if (inString) {
|
|
241
|
-
if (c === "\\") {
|
|
242
|
-
i++;
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
if (c === '"')
|
|
246
|
-
inString = false;
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
if (c === '"') {
|
|
250
|
-
inString = true;
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
if (c === open)
|
|
254
|
-
depth++;
|
|
255
|
-
else if (c === close) {
|
|
256
|
-
depth--;
|
|
257
|
-
if (depth === 0) {
|
|
258
|
-
i++;
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return i;
|
|
264
|
-
}
|
|
265
|
-
while (i < text.length && !",}]".includes(text[i]))
|
|
266
|
-
i++;
|
|
267
|
-
return i;
|
|
268
|
-
}
|
|
269
|
-
function stripTopLevelJsonKeys(text, keysToStrip) {
|
|
270
|
-
const objStart = text.indexOf("{");
|
|
271
|
-
if (objStart === -1)
|
|
272
|
-
return text;
|
|
273
|
-
let out = text.slice(0, objStart + 1);
|
|
274
|
-
let i = objStart + 1;
|
|
275
|
-
let wroteField = false;
|
|
276
|
-
while (i < text.length) {
|
|
277
|
-
while (i < text.length && /\s/.test(text[i]))
|
|
278
|
-
i++;
|
|
279
|
-
if (text[i] === "}" || i >= text.length) {
|
|
280
|
-
out += text.slice(i);
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
if (text[i] === ",") {
|
|
284
|
-
i++;
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
const keyStart = i;
|
|
288
|
-
const keyTextEnd = skipJsonValue(text, keyStart);
|
|
289
|
-
let key;
|
|
290
|
-
try {
|
|
291
|
-
key = JSON.parse(text.slice(keyStart, keyTextEnd));
|
|
292
|
-
} catch {
|
|
293
|
-
return text;
|
|
294
|
-
}
|
|
295
|
-
let j = keyTextEnd;
|
|
296
|
-
while (j < text.length && /\s/.test(text[j]))
|
|
297
|
-
j++;
|
|
298
|
-
const valueStart = j + 1;
|
|
299
|
-
const valueEnd = skipJsonValue(text, valueStart);
|
|
300
|
-
if (!keysToStrip.has(key)) {
|
|
301
|
-
out += (wroteField ? "," : "") + text.slice(keyStart, valueEnd);
|
|
302
|
-
wroteField = true;
|
|
303
|
-
}
|
|
304
|
-
i = valueEnd;
|
|
305
|
-
}
|
|
306
|
-
return out;
|
|
307
|
-
}
|
|
308
|
-
export function _stripTopLevelJsonKeysForTests(text, keysToStrip) {
|
|
309
|
-
return stripTopLevelJsonKeys(text, new Set(keysToStrip));
|
|
310
|
-
}
|
|
311
|
-
const HEAVY_SNAPSHOT_KEYS = new Set([
|
|
312
|
-
"wordIndex",
|
|
313
|
-
"files",
|
|
314
|
-
"symbols",
|
|
315
|
-
"reverseDeps"
|
|
316
|
-
]);
|
|
317
|
-
const NARROW_DIGEST_HEAVY_KEY_LITERALS = [
|
|
318
|
-
"wordIndex",
|
|
319
|
-
"files",
|
|
320
|
-
"symbols",
|
|
321
|
-
"reverseDeps"
|
|
322
|
-
];
|
|
323
|
-
let _lastNarrowParseDigestForTests;
|
|
324
|
-
export function getLastNarrowParseDigestForTests() {
|
|
325
|
-
return _lastNarrowParseDigestForTests;
|
|
326
|
-
}
|
|
327
|
-
export function resetLastNarrowParseDigestForTests() {
|
|
328
|
-
_lastNarrowParseDigestForTests = undefined;
|
|
329
|
-
}
|
|
330
|
-
function parseExportsAndRulesOnly(json) {
|
|
331
|
-
const narrowed = stripTopLevelJsonKeys(json, HEAVY_SNAPSHOT_KEYS);
|
|
332
|
-
_lastNarrowParseDigestForTests = {
|
|
333
|
-
length: narrowed.length,
|
|
334
|
-
containsHeavyKey: NARROW_DIGEST_HEAVY_KEY_LITERALS.some((key) => narrowed.includes(`"${key}":`))
|
|
335
|
-
};
|
|
336
|
-
const parsed = JSON.parse(narrowed);
|
|
337
|
-
if (parsed.version !== PROJECT_SNAPSHOT_VERSION)
|
|
338
|
-
return null;
|
|
339
|
-
if (typeof parsed.seq !== "number")
|
|
340
|
-
return null;
|
|
341
|
-
if (!Array.isArray(parsed.cachedExports))
|
|
342
|
-
return null;
|
|
343
|
-
return {
|
|
344
|
-
version: PROJECT_SNAPSHOT_VERSION,
|
|
345
|
-
seq: parsed.seq,
|
|
346
|
-
cachedExports: parsed.cachedExports.filter((entry) => Array.isArray(entry) && typeof entry[0] === "string" && typeof entry[1] === "string"),
|
|
347
|
-
projectRulesScan: parsed.projectRulesScan
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
function readSnapshotExportsAndRulesBody(bodyPath, gz) {
|
|
351
|
-
try {
|
|
352
|
-
const json = gz ? gunzipSync(fs.readFileSync(bodyPath)).toString("utf-8") : fs.readFileSync(bodyPath, "utf-8");
|
|
353
|
-
return parseExportsAndRulesOnly(json);
|
|
354
|
-
} catch (err) {
|
|
355
|
-
logLatency({
|
|
356
|
-
type: "phase",
|
|
357
|
-
phase: "project_snapshot_body_corrupt",
|
|
358
|
-
filePath: bodyPath,
|
|
359
|
-
durationMs: 0,
|
|
360
|
-
metadata: {
|
|
361
|
-
error: err instanceof Error ? err.message : String(err),
|
|
362
|
-
narrow: true
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
return null;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
export function loadProjectSnapshotExportsAndRules(cwd) {
|
|
369
|
-
const key = normalizeMapKey(cwd);
|
|
370
|
-
const body = resolveSnapshotBodyPath(cwd);
|
|
371
|
-
const authoritative = authoritativeSnapshots.get(key);
|
|
372
|
-
if (authoritative) {
|
|
373
|
-
const notSuperseded = body === null || body.mtimeMs <= authoritative.knownMtime && body.size === authoritative.knownSize;
|
|
374
|
-
if (notSuperseded) {
|
|
375
|
-
const { version, seq, cachedExports, projectRulesScan } = authoritative.snapshot;
|
|
376
|
-
return { version, seq, cachedExports, projectRulesScan };
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
if (!body)
|
|
380
|
-
return null;
|
|
381
|
-
return readSnapshotExportsAndRulesBody(body.path, body.gz);
|
|
382
|
-
}
|
|
383
|
-
function loadProjectSnapshotInternal(cwd, requireWordIndex) {
|
|
384
|
-
const key = normalizeMapKey(cwd);
|
|
385
|
-
const body = resolveSnapshotBodyPath(cwd);
|
|
386
|
-
const authoritative = authoritativeSnapshots.get(key);
|
|
387
|
-
if (authoritative) {
|
|
388
|
-
const notSuperseded = body === null || body.mtimeMs <= authoritative.knownMtime && body.size === authoritative.knownSize;
|
|
389
|
-
if (notSuperseded) {
|
|
390
|
-
touchAuthoritativeSnapshot(key, authoritative);
|
|
391
|
-
return authoritative.snapshot;
|
|
392
|
-
}
|
|
393
|
-
deleteAuthoritativeSnapshot(key);
|
|
394
|
-
}
|
|
395
|
-
if (!body) {
|
|
396
|
-
snapshotParseCache.delete(getProjectSnapshotPath(cwd));
|
|
397
|
-
return null;
|
|
398
|
-
}
|
|
399
|
-
const cacheKey = body.path;
|
|
400
|
-
const cached = snapshotParseCache.get(cacheKey);
|
|
401
|
-
if (cached && cached.mtimeMs === body.mtimeMs && cached.size === body.size) {
|
|
402
|
-
if (!requireWordIndex || !cached.snapshot || cached.snapshot.wordIndex) {
|
|
403
|
-
return cached.snapshot;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
const { snapshot, rawBytes } = readSnapshotBody(body.path, body.gz);
|
|
407
|
-
const cacheSnapshot = withoutWordIndex(snapshot);
|
|
408
|
-
if (rawBytes > 0 && (rawBytes <= SNAPSHOT_PARSE_CACHE_MAX_BYTES || snapshot?.wordIndex)) {
|
|
409
|
-
cacheParsedSnapshot(cacheKey, {
|
|
410
|
-
mtimeMs: body.mtimeMs,
|
|
411
|
-
size: body.size,
|
|
412
|
-
snapshot: cacheSnapshot
|
|
413
|
-
});
|
|
414
|
-
} else {
|
|
415
|
-
snapshotParseCache.delete(cacheKey);
|
|
416
|
-
}
|
|
417
|
-
return snapshot;
|
|
418
|
-
}
|
|
419
|
-
export function loadProjectSnapshot(cwd) {
|
|
420
|
-
return loadProjectSnapshotInternal(cwd, true);
|
|
421
|
-
}
|
|
422
|
-
export function loadProjectSnapshotWithoutWordIndex(cwd) {
|
|
423
|
-
return loadProjectSnapshotInternal(cwd, false);
|
|
424
|
-
}
|
|
425
|
-
const _snapshotGenerationStates = new Map;
|
|
426
|
-
const _successfulSnapshotPersists = new BoundedFifoMap(PROJECT_SNAPSHOT_MAX_WARM_ROOTS);
|
|
427
|
-
const _failedSnapshotPersists = new BoundedFifoMap(PROJECT_SNAPSHOT_MAX_WARM_ROOTS);
|
|
428
|
-
const _activeSnapshotPersists = new Map;
|
|
429
|
-
const _queuedSnapshotPersists = new Map;
|
|
430
|
-
const _snapshotWorkerRequests = new Map;
|
|
431
|
-
let _snapshotPersistWorker;
|
|
432
|
-
let _snapshotWorkerRequestId = 0;
|
|
433
|
-
let _snapshotWorkerDisabled = false;
|
|
434
|
-
let _snapshotGenerationGateEnabledForTests = true;
|
|
435
|
-
let _snapshotPromotionSeamForTests;
|
|
436
|
-
let _lastSnapshotPersistErrorForTests;
|
|
437
|
-
let _snapshotExiting = false;
|
|
438
|
-
let _snapshotWorkerBodyWritesForTests = 0;
|
|
439
|
-
function snapshotWorkerEnabled() {
|
|
440
|
-
const raw = process.env.DM_LENS_SNAPSHOT_PERSIST_SYNC;
|
|
441
|
-
return !(raw === "1" || raw === "true");
|
|
442
|
-
}
|
|
443
|
-
function pendingSnapshotIsCurrent(pending) {
|
|
444
|
-
return !_snapshotGenerationGateEnabledForTests || _snapshotGenerationStates.get(pending.key)?.generation === pending.generation;
|
|
445
|
-
}
|
|
446
|
-
function rememberSuccessfulSnapshotPersist(key, record) {
|
|
447
|
-
_successfulSnapshotPersists.delete(key);
|
|
448
|
-
_successfulSnapshotPersists.set(key, record);
|
|
449
|
-
}
|
|
450
|
-
function assessSnapshotBodyIntegrity(meta, body) {
|
|
451
|
-
if (meta.gzBytes === undefined) {
|
|
452
|
-
return { outcome: "legacy-meta", actualBytes: body.size };
|
|
453
|
-
}
|
|
454
|
-
if (!body.gz || body.size !== meta.gzBytes) {
|
|
455
|
-
return {
|
|
456
|
-
outcome: "size-mismatch",
|
|
457
|
-
expectedGzBytes: meta.gzBytes,
|
|
458
|
-
actualBytes: body.size
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
return {
|
|
462
|
-
outcome: "ok",
|
|
463
|
-
expectedGzBytes: meta.gzBytes,
|
|
464
|
-
actualBytes: body.size
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
function noteSnapshotBodyIntegrityWithheld(args) {
|
|
468
|
-
incrementDegradationCount({
|
|
469
|
-
kind: "snapshot-integrity",
|
|
470
|
-
subject: args.gzPath,
|
|
471
|
-
reason: args.verdict
|
|
472
|
-
});
|
|
473
|
-
logLatency({
|
|
474
|
-
type: "phase",
|
|
475
|
-
phase: "project_snapshot_body_integrity",
|
|
476
|
-
filePath: args.gzPath,
|
|
477
|
-
durationMs: 0,
|
|
478
|
-
metadata: {
|
|
479
|
-
outcome: "dedupe_withheld",
|
|
480
|
-
reason: args.verdict,
|
|
481
|
-
...args.seq !== undefined ? { seq: args.seq } : {},
|
|
482
|
-
...args.expectedGzBytes === undefined ? {} : { expectedGzBytes: args.expectedGzBytes },
|
|
483
|
-
actualBytes: args.actualBytes
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
function noteSnapshotSkipRefused(args) {
|
|
488
|
-
logLatency({
|
|
489
|
-
type: "phase",
|
|
490
|
-
phase: "project_snapshot_body_integrity",
|
|
491
|
-
filePath: args.gzPath,
|
|
492
|
-
durationMs: 0,
|
|
493
|
-
metadata: {
|
|
494
|
-
outcome: "skip_refused_rewrite",
|
|
495
|
-
reason: args.verdict,
|
|
496
|
-
seq: args.seq
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
function snapshotPersistBaselinesFor(cwd, key) {
|
|
501
|
-
const local = _successfulSnapshotPersists.get(key);
|
|
502
|
-
const meta = readProjectSnapshotMeta(cwd);
|
|
503
|
-
const body = resolveSnapshotBodyPath(cwd);
|
|
504
|
-
if (!meta?.fingerprint || !body) {
|
|
505
|
-
if (!body)
|
|
506
|
-
_successfulSnapshotPersists.delete(key);
|
|
507
|
-
return { fingerprints: [] };
|
|
508
|
-
}
|
|
509
|
-
const integrity = assessSnapshotBodyIntegrity(meta, body);
|
|
510
|
-
if (integrity.outcome !== "ok") {
|
|
511
|
-
noteSnapshotBodyIntegrityWithheld({
|
|
512
|
-
gzPath: getProjectSnapshotPath(cwd),
|
|
513
|
-
verdict: integrity.outcome,
|
|
514
|
-
seq: meta.seq,
|
|
515
|
-
expectedGzBytes: integrity.expectedGzBytes,
|
|
516
|
-
actualBytes: integrity.actualBytes
|
|
517
|
-
});
|
|
518
|
-
return { fingerprints: [] };
|
|
519
|
-
}
|
|
520
|
-
const durable = {
|
|
521
|
-
seq: meta.seq,
|
|
522
|
-
fingerprint: meta.fingerprint,
|
|
523
|
-
generatedAt: meta.timestamp,
|
|
524
|
-
generation: _snapshotGenerationStates.get(key)?.generation ?? 0,
|
|
525
|
-
gzBytes: meta.gzBytes
|
|
526
|
-
};
|
|
527
|
-
const fingerprints = [durable.fingerprint];
|
|
528
|
-
if (local && local.fingerprint !== durable.fingerprint) {
|
|
529
|
-
fingerprints.push(local.fingerprint);
|
|
530
|
-
}
|
|
531
|
-
return { durable, fingerprints, integrity: "ok" };
|
|
532
|
-
}
|
|
533
|
-
function seedSnapshotPersistBaselineFromDurable(key, durable) {
|
|
534
|
-
if (!durable || _successfulSnapshotPersists.has(key))
|
|
535
|
-
return;
|
|
536
|
-
rememberSuccessfulSnapshotPersist(key, durable);
|
|
537
|
-
}
|
|
538
|
-
function writeProjectSnapshotMeta(metaPath, snapshot, bodyRecord) {
|
|
539
|
-
writeFileAtomic(metaPath, JSON.stringify({
|
|
540
|
-
timestamp: bodyRecord?.generatedAt ?? snapshot.generatedAt,
|
|
541
|
-
version: snapshot.version,
|
|
542
|
-
seq: snapshot.seq,
|
|
543
|
-
...bodyRecord ? {
|
|
544
|
-
fingerprint: bodyRecord.fingerprint,
|
|
545
|
-
...bodyRecord.gzBytes === undefined ? {} : { gzBytes: bodyRecord.gzBytes }
|
|
546
|
-
} : {},
|
|
547
|
-
...snapshot.sequenceIndex ? { sequenceIndex: snapshot.sequenceIndex } : {}
|
|
548
|
-
}), { bestEffort: false });
|
|
549
|
-
}
|
|
550
|
-
function recordSnapshotPersistFailure(pending, error, bodyPersisted = false) {
|
|
551
|
-
_lastSnapshotPersistErrorForTests = error;
|
|
552
|
-
_failedSnapshotPersists.set(pending.key, {
|
|
553
|
-
seq: pending.snapshot.seq,
|
|
554
|
-
generation: pending.generation
|
|
555
|
-
});
|
|
556
|
-
deleteAuthoritativeSnapshot(pending.key);
|
|
557
|
-
logLatency({
|
|
558
|
-
type: "phase",
|
|
559
|
-
phase: "project_snapshot_persist_failed",
|
|
560
|
-
filePath: pending.gzPath,
|
|
561
|
-
durationMs: 0,
|
|
562
|
-
metadata: {
|
|
563
|
-
error,
|
|
564
|
-
seq: pending.snapshot.seq,
|
|
565
|
-
outcome: bodyPersisted ? "metadata_repair_required" : "failed",
|
|
566
|
-
...bodyPersisted ? { bodyPersisted: true } : {}
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
function logSnapshotPersistSuccess(pending, fingerprint, stats) {
|
|
571
|
-
rememberSuccessfulSnapshotPersist(pending.key, {
|
|
572
|
-
seq: pending.snapshot.seq,
|
|
573
|
-
fingerprint,
|
|
574
|
-
generatedAt: pending.snapshot.generatedAt,
|
|
575
|
-
generation: pending.generation,
|
|
576
|
-
rawBytes: stats.rawBytes,
|
|
577
|
-
gzBytes: stats.gzBytes
|
|
578
|
-
});
|
|
579
|
-
_failedSnapshotPersists.delete(pending.key);
|
|
580
|
-
logLatency({
|
|
581
|
-
type: "phase",
|
|
582
|
-
phase: "project_snapshot_persist",
|
|
583
|
-
filePath: pending.gzPath,
|
|
584
|
-
durationMs: stats.serializeMs + stats.writeMs,
|
|
585
|
-
metadata: { seq: pending.snapshot.seq, outcome: "executed", ...stats }
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
function logSnapshotPersistDecision(args) {
|
|
589
|
-
logLatency({
|
|
590
|
-
type: "phase",
|
|
591
|
-
phase: "project_snapshot_persist_decision",
|
|
592
|
-
filePath: getProjectSnapshotPath(args.cwd),
|
|
593
|
-
durationMs: 0,
|
|
594
|
-
metadata: {
|
|
595
|
-
seq: args.seq,
|
|
596
|
-
decision: args.decision,
|
|
597
|
-
...args.fingerprint ? { fingerprint: args.fingerprint.slice(0, 12) } : {},
|
|
598
|
-
...args.avoidedRawBytes === undefined ? {} : { avoidedRawBytes: args.avoidedRawBytes },
|
|
599
|
-
...args.avoidedGzipBytes === undefined ? {} : { avoidedGzipBytes: args.avoidedGzipBytes }
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
function reconcileAuthoritativeAfterWrite(pending, rawBytes) {
|
|
604
|
-
const entry = authoritativeSnapshots.get(pending.key);
|
|
605
|
-
if (!entry || entry.snapshot !== pending.snapshot)
|
|
606
|
-
return;
|
|
607
|
-
if (pending.snapshot.wordIndex) {
|
|
608
|
-
try {
|
|
609
|
-
const stat = fs.statSync(pending.gzPath);
|
|
610
|
-
cacheParsedSnapshot(pending.gzPath, {
|
|
611
|
-
mtimeMs: stat.mtimeMs,
|
|
612
|
-
size: stat.size,
|
|
613
|
-
snapshot: withoutWordIndex(pending.snapshot)
|
|
614
|
-
});
|
|
615
|
-
} catch {}
|
|
616
|
-
deleteAuthoritativeSnapshot(pending.key);
|
|
617
|
-
logLatency({
|
|
618
|
-
type: "phase",
|
|
619
|
-
phase: "project_snapshot_word_index_released",
|
|
620
|
-
filePath: pending.gzPath,
|
|
621
|
-
durationMs: 0,
|
|
622
|
-
metadata: { rawBytes }
|
|
623
|
-
});
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
if (rawBytes > SNAPSHOT_PARSE_CACHE_MAX_BYTES) {
|
|
627
|
-
logLatency({
|
|
628
|
-
type: "phase",
|
|
629
|
-
phase: "project_snapshot_authoritative_dropped_oversized",
|
|
630
|
-
filePath: pending.gzPath,
|
|
631
|
-
durationMs: 0,
|
|
632
|
-
metadata: { rawBytes, maxBytes: SNAPSHOT_PARSE_CACHE_MAX_BYTES }
|
|
633
|
-
});
|
|
634
|
-
deleteAuthoritativeSnapshot(pending.key);
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
try {
|
|
638
|
-
const stat = fs.statSync(pending.gzPath);
|
|
639
|
-
entry.knownMtime = stat.mtimeMs;
|
|
640
|
-
entry.knownSize = stat.size;
|
|
641
|
-
} catch {}
|
|
642
|
-
}
|
|
643
|
-
function finalizeProjectSnapshotMeta(pending, record) {
|
|
644
|
-
try {
|
|
645
|
-
writeProjectSnapshotMeta(getProjectSnapshotMetaPath(pending.cwd), pending.snapshot, record);
|
|
646
|
-
return true;
|
|
647
|
-
} catch (err) {
|
|
648
|
-
recordSnapshotPersistFailure(pending, err instanceof Error ? err.message : String(err), true);
|
|
649
|
-
return false;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
function completeSnapshotPersist(pending) {
|
|
653
|
-
if (_activeSnapshotPersists.get(pending.key) !== pending)
|
|
654
|
-
return;
|
|
655
|
-
_activeSnapshotPersists.delete(pending.key);
|
|
656
|
-
if (_snapshotExiting)
|
|
657
|
-
return;
|
|
658
|
-
const queued = _queuedSnapshotPersists.get(pending.key);
|
|
659
|
-
if (!queued)
|
|
660
|
-
return;
|
|
661
|
-
_queuedSnapshotPersists.delete(pending.key);
|
|
662
|
-
dispatchSnapshotPersist(queued);
|
|
663
|
-
}
|
|
664
|
-
function writeSnapshotBodyOnMainThread(pending, reason) {
|
|
665
|
-
if (!pendingSnapshotIsCurrent(pending)) {
|
|
666
|
-
completeSnapshotPersist(pending);
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
if (reason) {
|
|
670
|
-
logLatency({
|
|
671
|
-
type: "phase",
|
|
672
|
-
phase: "project_snapshot_worker_fallback",
|
|
673
|
-
filePath: pending.gzPath,
|
|
674
|
-
durationMs: 0,
|
|
675
|
-
metadata: {
|
|
676
|
-
reason,
|
|
677
|
-
seq: pending.snapshot.seq,
|
|
678
|
-
degraded: reason !== "exit_hook"
|
|
679
|
-
}
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
try {
|
|
683
|
-
const serializeStarted = performance.now();
|
|
684
|
-
const json = JSON.stringify(pending.snapshot);
|
|
685
|
-
const serializeMs = performance.now() - serializeStarted;
|
|
686
|
-
const rawBytes = Buffer.byteLength(json);
|
|
687
|
-
const fingerprint = fingerprintProjectSnapshotJson(json, pending.snapshot.generatedAt);
|
|
688
|
-
if (pending.dedupeFingerprints.includes(fingerprint)) {
|
|
689
|
-
const current = snapshotPersistBaselinesFor(pending.cwd, pending.key);
|
|
690
|
-
if (current.integrity === "ok") {
|
|
691
|
-
const prior = current.durable ?? pending.durablePersist;
|
|
692
|
-
if (authoritativeSnapshots.get(pending.key)?.snapshot === pending.snapshot) {
|
|
693
|
-
deleteAuthoritativeSnapshot(pending.key);
|
|
694
|
-
}
|
|
695
|
-
logSnapshotPersistDecision({
|
|
696
|
-
cwd: pending.cwd,
|
|
697
|
-
seq: pending.snapshot.seq,
|
|
698
|
-
fingerprint,
|
|
699
|
-
decision: "skipped_unchanged",
|
|
700
|
-
avoidedRawBytes: rawBytes,
|
|
701
|
-
avoidedGzipBytes: prior?.gzBytes
|
|
702
|
-
});
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
if (current.integrity !== undefined) {
|
|
706
|
-
noteSnapshotSkipRefused({
|
|
707
|
-
gzPath: pending.gzPath,
|
|
708
|
-
verdict: current.integrity,
|
|
709
|
-
seq: pending.snapshot.seq
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
const writeStarted = performance.now();
|
|
714
|
-
const gzip = gzipSync(json);
|
|
715
|
-
fs.mkdirSync(path.dirname(pending.gzPath), { recursive: true });
|
|
716
|
-
writeFileAtomic(pending.gzPath, gzip, { bestEffort: false });
|
|
717
|
-
fs.rmSync(pending.legacyPath, { force: true });
|
|
718
|
-
const metadataFinalized = finalizeProjectSnapshotMeta(pending, {
|
|
719
|
-
fingerprint,
|
|
720
|
-
generatedAt: pending.snapshot.generatedAt,
|
|
721
|
-
gzBytes: gzip.byteLength
|
|
722
|
-
});
|
|
723
|
-
if (!metadataFinalized)
|
|
724
|
-
return;
|
|
725
|
-
reconcileAuthoritativeAfterWrite(pending, rawBytes);
|
|
726
|
-
logSnapshotPersistSuccess(pending, fingerprint, {
|
|
727
|
-
rawBytes,
|
|
728
|
-
gzBytes: gzip.byteLength,
|
|
729
|
-
serializeMs,
|
|
730
|
-
writeMs: performance.now() - writeStarted,
|
|
731
|
-
offloaded: false
|
|
732
|
-
});
|
|
733
|
-
if (reason)
|
|
734
|
-
_lastSnapshotPersistErrorForTests = reason;
|
|
735
|
-
} catch (err) {
|
|
736
|
-
recordSnapshotPersistFailure(pending, err instanceof Error ? err.message : String(err));
|
|
737
|
-
} finally {
|
|
738
|
-
completeSnapshotPersist(pending);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
function dispatchMainThreadWriteThroughSeam(pending, reason) {
|
|
742
|
-
if (_snapshotPromotionSeamForTests) {
|
|
743
|
-
_snapshotPromotionSeamForTests().then(() => writeSnapshotBodyOnMainThread(pending, reason));
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
writeSnapshotBodyOnMainThread(pending, reason);
|
|
747
|
-
}
|
|
748
|
-
function handleSnapshotWorkerResult(result) {
|
|
749
|
-
const pending = _snapshotWorkerRequests.get(result.id);
|
|
750
|
-
if (!pending) {
|
|
751
|
-
fs.rmSync(result.stagePath, { force: true });
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
|
-
_snapshotWorkerRequests.delete(result.id);
|
|
755
|
-
if (result.error || result.rawBytes === undefined || result.gzBytes === undefined || result.serializeMs === undefined || result.writeMs === undefined || result.semanticFingerprint === undefined) {
|
|
756
|
-
fs.rmSync(result.stagePath, { force: true });
|
|
757
|
-
dispatchMainThreadWriteThroughSeam(pending, result.error ?? "invalid worker result");
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
if (!result.skippedUnchanged)
|
|
761
|
-
_snapshotWorkerBodyWritesForTests++;
|
|
762
|
-
if (_snapshotGenerationGateEnabledForTests && _snapshotGenerationStates.get(pending.key)?.generation !== result.generation) {
|
|
763
|
-
fs.rmSync(result.stagePath, { force: true });
|
|
764
|
-
completeSnapshotPersist(pending);
|
|
765
|
-
return;
|
|
766
|
-
}
|
|
767
|
-
if (result.skippedUnchanged) {
|
|
768
|
-
const baselines = snapshotPersistBaselinesFor(pending.cwd, pending.key);
|
|
769
|
-
if (baselines.integrity !== "ok") {
|
|
770
|
-
if (baselines.integrity !== undefined) {
|
|
771
|
-
noteSnapshotSkipRefused({
|
|
772
|
-
gzPath: pending.gzPath,
|
|
773
|
-
verdict: baselines.integrity,
|
|
774
|
-
seq: pending.snapshot.seq
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
dispatchMainThreadWriteThroughSeam(pending, "snapshot body integrity regressed");
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
const prior = baselines.durable ?? pending.durablePersist;
|
|
781
|
-
if (authoritativeSnapshots.get(pending.key)?.snapshot === pending.snapshot) {
|
|
782
|
-
deleteAuthoritativeSnapshot(pending.key);
|
|
783
|
-
}
|
|
784
|
-
logSnapshotPersistDecision({
|
|
785
|
-
cwd: pending.cwd,
|
|
786
|
-
seq: pending.snapshot.seq,
|
|
787
|
-
fingerprint: result.semanticFingerprint,
|
|
788
|
-
decision: "skipped_unchanged",
|
|
789
|
-
avoidedRawBytes: result.rawBytes,
|
|
790
|
-
avoidedGzipBytes: prior?.gzBytes
|
|
791
|
-
});
|
|
792
|
-
completeSnapshotPersist(pending);
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
try {
|
|
796
|
-
fs.renameSync(result.stagePath, pending.gzPath);
|
|
797
|
-
fs.rmSync(pending.legacyPath, { force: true });
|
|
798
|
-
const metadataFinalized = finalizeProjectSnapshotMeta(pending, {
|
|
799
|
-
fingerprint: result.semanticFingerprint,
|
|
800
|
-
generatedAt: pending.snapshot.generatedAt,
|
|
801
|
-
gzBytes: result.gzBytes
|
|
802
|
-
});
|
|
803
|
-
if (!metadataFinalized) {
|
|
804
|
-
completeSnapshotPersist(pending);
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
reconcileAuthoritativeAfterWrite(pending, result.rawBytes);
|
|
808
|
-
logSnapshotPersistSuccess(pending, result.semanticFingerprint, {
|
|
809
|
-
rawBytes: result.rawBytes,
|
|
810
|
-
gzBytes: result.gzBytes,
|
|
811
|
-
serializeMs: result.serializeMs,
|
|
812
|
-
writeMs: result.writeMs,
|
|
813
|
-
offloaded: true
|
|
814
|
-
});
|
|
815
|
-
completeSnapshotPersist(pending);
|
|
816
|
-
} catch (err) {
|
|
817
|
-
fs.rm(result.stagePath, { force: true }, () => {});
|
|
818
|
-
dispatchMainThreadWriteThroughSeam(pending, err instanceof Error ? err.message : String(err));
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
function dispatchSnapshotPersist(pending) {
|
|
822
|
-
const baselines = snapshotPersistBaselinesFor(pending.cwd, pending.key);
|
|
823
|
-
pending.durablePersist = baselines.durable;
|
|
824
|
-
pending.dedupeFingerprints = baselines.fingerprints;
|
|
825
|
-
seedSnapshotPersistBaselineFromDurable(pending.key, baselines.durable);
|
|
826
|
-
_activeSnapshotPersists.set(pending.key, pending);
|
|
827
|
-
if (!snapshotWorkerEnabled()) {
|
|
828
|
-
dispatchMainThreadWriteThroughSeam(pending, undefined);
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
const worker = getSnapshotPersistWorker();
|
|
832
|
-
if (!worker) {
|
|
833
|
-
dispatchMainThreadWriteThroughSeam(pending, "persist worker unavailable");
|
|
834
|
-
return;
|
|
835
|
-
}
|
|
836
|
-
const id = ++_snapshotWorkerRequestId;
|
|
837
|
-
_snapshotWorkerRequests.set(id, pending);
|
|
838
|
-
const request = {
|
|
839
|
-
id,
|
|
840
|
-
generation: pending.generation,
|
|
841
|
-
stagePath: pending.stagePath,
|
|
842
|
-
data: pending.snapshot,
|
|
843
|
-
priorFingerprints: pending.dedupeFingerprints,
|
|
844
|
-
testDelayMs: undefined
|
|
845
|
-
};
|
|
846
|
-
try {
|
|
847
|
-
worker.postMessage(request);
|
|
848
|
-
} catch (err) {
|
|
849
|
-
_snapshotWorkerRequests.delete(id);
|
|
850
|
-
dispatchMainThreadWriteThroughSeam(pending, err instanceof Error ? err.message : String(err));
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
function handleSnapshotWorkerDeath(reason) {
|
|
854
|
-
_snapshotPersistWorker = undefined;
|
|
855
|
-
_snapshotWorkerDisabled = true;
|
|
856
|
-
const requests = [..._snapshotWorkerRequests.values()];
|
|
857
|
-
_snapshotWorkerRequests.clear();
|
|
858
|
-
for (const pending of requests)
|
|
859
|
-
dispatchMainThreadWriteThroughSeam(pending, reason);
|
|
860
|
-
}
|
|
861
|
-
function resolveSnapshotPersistWorkerPath() {
|
|
862
|
-
const candidates = [
|
|
863
|
-
new URL("./project-snapshot-persist-worker.js", import.meta.url),
|
|
864
|
-
new URL("./clients/project-snapshot-persist-worker.js", import.meta.url)
|
|
865
|
-
];
|
|
866
|
-
for (const url of candidates) {
|
|
867
|
-
try {
|
|
868
|
-
const resolved = fileURLToPath(url);
|
|
869
|
-
if (fs.existsSync(resolved))
|
|
870
|
-
return resolved;
|
|
871
|
-
} catch {}
|
|
872
|
-
}
|
|
873
|
-
return;
|
|
874
|
-
}
|
|
875
|
-
function getSnapshotPersistWorker() {
|
|
876
|
-
if (_snapshotWorkerDisabled)
|
|
877
|
-
return;
|
|
878
|
-
if (_snapshotPersistWorker)
|
|
879
|
-
return _snapshotPersistWorker;
|
|
880
|
-
try {
|
|
881
|
-
const workerPath = resolveSnapshotPersistWorkerPath();
|
|
882
|
-
if (workerPath === undefined) {
|
|
883
|
-
handleSnapshotWorkerDeath("persist worker script not found in any layout");
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
const worker = new Worker(workerPath);
|
|
887
|
-
worker.on("message", (result) => {
|
|
888
|
-
if (_snapshotPromotionSeamForTests) {
|
|
889
|
-
_snapshotPromotionSeamForTests().then(() => handleSnapshotWorkerResult(result));
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
handleSnapshotWorkerResult(result);
|
|
893
|
-
});
|
|
894
|
-
worker.on("error", (err) => handleSnapshotWorkerDeath(err.message));
|
|
895
|
-
worker.on("exit", (code) => {
|
|
896
|
-
if (_snapshotPersistWorker === worker)
|
|
897
|
-
_snapshotPersistWorker = undefined;
|
|
898
|
-
const stranded = [..._snapshotWorkerRequests.values()];
|
|
899
|
-
if (stranded.length > 0) {
|
|
900
|
-
_snapshotWorkerRequests.clear();
|
|
901
|
-
for (const pending of stranded) {
|
|
902
|
-
dispatchMainThreadWriteThroughSeam(pending, `persist worker exited with code ${code}`);
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
if (code !== 0)
|
|
906
|
-
_snapshotWorkerDisabled = true;
|
|
907
|
-
});
|
|
908
|
-
worker.unref();
|
|
909
|
-
_snapshotPersistWorker = worker;
|
|
910
|
-
return worker;
|
|
911
|
-
} catch (err) {
|
|
912
|
-
handleSnapshotWorkerDeath(err instanceof Error ? err.message : String(err));
|
|
913
|
-
return;
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
const _sweptSnapshotStageDirs = new Set;
|
|
917
|
-
function sweepStaleSnapshotStageFiles(cacheDir) {
|
|
918
|
-
if (_sweptSnapshotStageDirs.has(cacheDir))
|
|
919
|
-
return;
|
|
920
|
-
_sweptSnapshotStageDirs.add(cacheDir);
|
|
921
|
-
fs.readdir(cacheDir, (err, entries) => {
|
|
922
|
-
if (err)
|
|
923
|
-
return;
|
|
924
|
-
const ownMarker = `.stage-${process.pid}-`;
|
|
925
|
-
for (const entry of entries) {
|
|
926
|
-
if (!entry.startsWith("project-snapshot.json.gz.stage-"))
|
|
927
|
-
continue;
|
|
928
|
-
if (entry.includes(ownMarker))
|
|
929
|
-
continue;
|
|
930
|
-
fs.rm(path.join(cacheDir, entry), { force: true }, () => {});
|
|
931
|
-
}
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
|
-
let _snapshotExitHookInstalled = false;
|
|
935
|
-
function ensureSnapshotPersistExitHook() {
|
|
936
|
-
if (_snapshotExitHookInstalled)
|
|
937
|
-
return;
|
|
938
|
-
_snapshotExitHookInstalled = true;
|
|
939
|
-
process.once("exit", () => {
|
|
940
|
-
_snapshotExiting = true;
|
|
941
|
-
const latestByKey = new Map;
|
|
942
|
-
for (const pending of _snapshotWorkerRequests.values()) {
|
|
943
|
-
latestByKey.set(pending.key, pending);
|
|
944
|
-
}
|
|
945
|
-
for (const pending of _queuedSnapshotPersists.values()) {
|
|
946
|
-
const prior = latestByKey.get(pending.key);
|
|
947
|
-
if (!prior || prior.generation <= pending.generation) {
|
|
948
|
-
latestByKey.set(pending.key, pending);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
_snapshotWorkerRequests.clear();
|
|
952
|
-
_queuedSnapshotPersists.clear();
|
|
953
|
-
_activeSnapshotPersists.clear();
|
|
954
|
-
for (const pending of latestByKey.values()) {
|
|
955
|
-
if (_snapshotGenerationStates.get(pending.key)?.generation !== pending.generation)
|
|
956
|
-
continue;
|
|
957
|
-
writeSnapshotBodyOnMainThread(pending, "exit_hook");
|
|
958
|
-
}
|
|
959
|
-
_snapshotPersistWorker?.terminate();
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
export function saveProjectSnapshot(cwd, snapshot) {
|
|
963
|
-
const gzPath = getProjectSnapshotPath(cwd);
|
|
964
|
-
const legacyPath = getProjectSnapshotLegacyPath(cwd);
|
|
965
|
-
const metaPath = getProjectSnapshotMetaPath(cwd);
|
|
966
|
-
const cacheDir = path.dirname(gzPath);
|
|
967
|
-
const key = normalizeMapKey(cwd);
|
|
968
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
969
|
-
const baselines = snapshotPersistBaselinesFor(cwd, key);
|
|
970
|
-
const priorPersist = baselines.durable;
|
|
971
|
-
logSnapshotPersistDecision({
|
|
972
|
-
cwd,
|
|
973
|
-
seq: snapshot.seq,
|
|
974
|
-
decision: "requested"
|
|
975
|
-
});
|
|
976
|
-
if (_failedSnapshotPersists.delete(key)) {
|
|
977
|
-
logSnapshotPersistDecision({ cwd, seq: snapshot.seq, decision: "retry" });
|
|
978
|
-
}
|
|
979
|
-
if (priorPersist?.seq !== snapshot.seq) {
|
|
980
|
-
writeProjectSnapshotMeta(metaPath, snapshot);
|
|
981
|
-
}
|
|
982
|
-
const priorBody = resolveSnapshotBodyPath(cwd);
|
|
983
|
-
const knownMtime = priorBody ? priorBody.mtimeMs : Number.NEGATIVE_INFINITY;
|
|
984
|
-
const knownSize = priorBody ? priorBody.size : Number.NEGATIVE_INFINITY;
|
|
985
|
-
const authoritativeEntry = {
|
|
986
|
-
snapshot,
|
|
987
|
-
knownMtime,
|
|
988
|
-
knownSize,
|
|
989
|
-
lastUsedAt: Date.now()
|
|
990
|
-
};
|
|
991
|
-
const previousAuthoritativeEntry = authoritativeSnapshots.get(key);
|
|
992
|
-
if (previousAuthoritativeEntry)
|
|
993
|
-
clearAuthoritativeSnapshotTimer(previousAuthoritativeEntry);
|
|
994
|
-
authoritativeSnapshots.set(key, authoritativeEntry);
|
|
995
|
-
scheduleAuthoritativeSnapshotEviction(key, authoritativeEntry);
|
|
996
|
-
enforceAuthoritativeSnapshotCap();
|
|
997
|
-
snapshotParseCache.delete(gzPath);
|
|
998
|
-
const generationState = _snapshotGenerationStates.get(key);
|
|
999
|
-
const generation = generationState?.seq === snapshot.seq ? generationState.generation : (generationState?.generation ?? 0) + 1;
|
|
1000
|
-
_snapshotGenerationStates.set(key, { generation, seq: snapshot.seq });
|
|
1001
|
-
const stagePath = `${gzPath}.stage-${process.pid}-${generation}`;
|
|
1002
|
-
const pending = {
|
|
1003
|
-
key,
|
|
1004
|
-
cwd,
|
|
1005
|
-
gzPath,
|
|
1006
|
-
legacyPath,
|
|
1007
|
-
stagePath,
|
|
1008
|
-
snapshot,
|
|
1009
|
-
generation,
|
|
1010
|
-
durablePersist: priorPersist,
|
|
1011
|
-
dedupeFingerprints: baselines.fingerprints
|
|
1012
|
-
};
|
|
1013
|
-
sweepStaleSnapshotStageFiles(cacheDir);
|
|
1014
|
-
ensureSnapshotPersistExitHook();
|
|
1015
|
-
if (_activeSnapshotPersists.has(key)) {
|
|
1016
|
-
_queuedSnapshotPersists.set(key, pending);
|
|
1017
|
-
logSnapshotPersistDecision({
|
|
1018
|
-
cwd,
|
|
1019
|
-
seq: snapshot.seq,
|
|
1020
|
-
decision: "coalesced"
|
|
1021
|
-
});
|
|
1022
|
-
return;
|
|
1023
|
-
}
|
|
1024
|
-
dispatchSnapshotPersist(pending);
|
|
1025
|
-
}
|
|
1026
|
-
export async function waitForProjectSnapshotPersistsForTests() {
|
|
1027
|
-
for (let attempts = 0;attempts < 200 && (_snapshotWorkerRequests.size > 0 || _activeSnapshotPersists.size > 0 || _queuedSnapshotPersists.size > 0); attempts++) {
|
|
1028
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
export function flushProjectSnapshotPersistsForTests() {
|
|
1032
|
-
const requests = [..._snapshotWorkerRequests.values()];
|
|
1033
|
-
_snapshotWorkerRequests.clear();
|
|
1034
|
-
for (const pending of requests) {
|
|
1035
|
-
dispatchMainThreadWriteThroughSeam(pending, undefined);
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
export async function terminateProjectSnapshotPersistWorkerForTests() {
|
|
1039
|
-
const worker = _snapshotPersistWorker;
|
|
1040
|
-
if (worker)
|
|
1041
|
-
await worker.terminate();
|
|
1042
|
-
}
|
|
1043
|
-
export function resetProjectSnapshotPersistWorkerForTests() {
|
|
1044
|
-
_snapshotWorkerDisabled = false;
|
|
1045
|
-
_snapshotGenerationGateEnabledForTests = true;
|
|
1046
|
-
_snapshotPromotionSeamForTests = undefined;
|
|
1047
|
-
_snapshotPersistWorker = undefined;
|
|
1048
|
-
_snapshotWorkerRequests.clear();
|
|
1049
|
-
_snapshotGenerationStates.clear();
|
|
1050
|
-
_successfulSnapshotPersists.clear();
|
|
1051
|
-
_failedSnapshotPersists.clear();
|
|
1052
|
-
_activeSnapshotPersists.clear();
|
|
1053
|
-
_queuedSnapshotPersists.clear();
|
|
1054
|
-
_snapshotExiting = false;
|
|
1055
|
-
_snapshotWorkerBodyWritesForTests = 0;
|
|
1056
|
-
_lastSnapshotPersistErrorForTests = undefined;
|
|
1057
|
-
}
|
|
1058
|
-
export function getProjectSnapshotPersistStateForTests(cwd) {
|
|
1059
|
-
const key = normalizeMapKey(cwd);
|
|
1060
|
-
return {
|
|
1061
|
-
active: _activeSnapshotPersists.has(key),
|
|
1062
|
-
queued: _queuedSnapshotPersists.has(key),
|
|
1063
|
-
successfulFingerprint: _successfulSnapshotPersists.get(key)?.fingerprint,
|
|
1064
|
-
workerBodyWrites: _snapshotWorkerBodyWritesForTests
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
export function setProjectSnapshotGenerationGateForTests(enabled) {
|
|
1068
|
-
_snapshotGenerationGateEnabledForTests = enabled;
|
|
1069
|
-
}
|
|
1070
|
-
export function setProjectSnapshotPromotionSeamForTests(seam) {
|
|
1071
|
-
_snapshotPromotionSeamForTests = seam;
|
|
1072
|
-
}
|
|
1073
|
-
export function getProjectSnapshotPersistErrorForTests() {
|
|
1074
|
-
return _lastSnapshotPersistErrorForTests;
|
|
1075
|
-
}
|
|
1076
|
-
export function _seedSnapshotParseCacheForTests(key, entry) {
|
|
1077
|
-
cacheParsedSnapshot(key, entry);
|
|
1078
|
-
}
|
|
1079
|
-
export function _snapshotParseCacheKeysForTests() {
|
|
1080
|
-
return [...snapshotParseCache.keys()];
|
|
1081
|
-
}
|
|
1082
|
-
export function _snapshotParseCacheGetForTests(key) {
|
|
1083
|
-
return snapshotParseCache.get(key) !== undefined;
|
|
1084
|
-
}
|
|
1085
|
-
export function _seedSuccessfulSnapshotPersistForTests(key, record) {
|
|
1086
|
-
rememberSuccessfulSnapshotPersist(key, record);
|
|
1087
|
-
}
|
|
1088
|
-
export function _successfulSnapshotPersistKeysForTests() {
|
|
1089
|
-
return [..._successfulSnapshotPersists.keys()];
|
|
1090
|
-
}
|
|
1091
|
-
export function _successfulSnapshotPersistGetForTests(key) {
|
|
1092
|
-
return _successfulSnapshotPersists.get(key) !== undefined;
|
|
1093
|
-
}
|
|
1094
|
-
export function _seedFailedSnapshotPersistForTests(key, record) {
|
|
1095
|
-
_failedSnapshotPersists.set(key, record);
|
|
1096
|
-
}
|
|
1097
|
-
export function _failedSnapshotPersistKeysForTests() {
|
|
1098
|
-
return [..._failedSnapshotPersists.keys()];
|
|
1099
|
-
}
|
|
1100
|
-
export function buildProjectSnapshotFromRuntime(args) {
|
|
1101
|
-
return {
|
|
1102
|
-
version: PROJECT_SNAPSHOT_VERSION,
|
|
1103
|
-
projectRoot: normalizeMapKey(path.resolve(args.cwd)),
|
|
1104
|
-
generatedAt: new Date().toISOString(),
|
|
1105
|
-
seq: args.runtime.projectSeq,
|
|
1106
|
-
files: {},
|
|
1107
|
-
symbols: {},
|
|
1108
|
-
reverseDeps: {},
|
|
1109
|
-
cachedExports: [...args.runtime.cachedExports.entries()].sort((a, b) => a[0].localeCompare(b[0])),
|
|
1110
|
-
sequenceIndex: {
|
|
1111
|
-
projectSeq: args.runtime.projectSeq,
|
|
1112
|
-
fileSeqByPath: args.runtime.getFileSeqEntries()
|
|
1113
|
-
},
|
|
1114
|
-
wordIndex: args.runtime.wordIndex ? serializeWordIndex(args.runtime.wordIndex) : undefined,
|
|
1115
|
-
projectRulesScan: args.runtime.projectRulesScan,
|
|
1116
|
-
startupScan: args.startupScan,
|
|
1117
|
-
languageProfile: args.languageProfile,
|
|
1118
|
-
conventions: args.conventions
|
|
1119
|
-
};
|
|
1120
|
-
}
|
|
1121
|
-
export function hydrateRuntimeFromProjectSnapshot(runtime, snapshot) {
|
|
1122
|
-
runtime.cachedExports.clear();
|
|
1123
|
-
for (const [name, filePath] of snapshot.cachedExports) {
|
|
1124
|
-
runtime.cachedExports.set(name, filePath);
|
|
1125
|
-
}
|
|
1126
|
-
if (snapshot.projectRulesScan) {
|
|
1127
|
-
runtime.projectRulesScan = snapshot.projectRulesScan;
|
|
1128
|
-
}
|
|
1129
|
-
runtime.wordIndex = deserializeWordIndex(snapshot.wordIndex);
|
|
1130
|
-
}
|
|
1131
|
-
export function hydrateRuntimeFromProjectSnapshotIfIdle(runtime, snapshot) {
|
|
1132
|
-
let hydratedAnything = false;
|
|
1133
|
-
if (runtime.cachedExports.size === 0 && snapshot.cachedExports.length > 0) {
|
|
1134
|
-
runtime.cachedExports.clear();
|
|
1135
|
-
for (const [name, filePath] of snapshot.cachedExports) {
|
|
1136
|
-
runtime.cachedExports.set(name, filePath);
|
|
1137
|
-
}
|
|
1138
|
-
hydratedAnything = true;
|
|
1139
|
-
}
|
|
1140
|
-
if (!runtime.projectRulesScan.hasCustomRules && runtime.projectRulesScan.rules.length === 0 && snapshot.projectRulesScan) {
|
|
1141
|
-
runtime.projectRulesScan = snapshot.projectRulesScan;
|
|
1142
|
-
hydratedAnything = true;
|
|
1143
|
-
}
|
|
1144
|
-
return hydratedAnything;
|
|
1145
|
-
}
|
|
1146
|
-
export function saveRuntimeProjectSnapshot(args) {
|
|
1147
|
-
try {
|
|
1148
|
-
if (typeof args.runtime.projectSeq !== "number")
|
|
1149
|
-
return;
|
|
1150
|
-
const existing = loadProjectSnapshot(args.cwd);
|
|
1151
|
-
let conventions = args.conventions ?? existing?.conventions;
|
|
1152
|
-
if (!conventions) {
|
|
1153
|
-
try {
|
|
1154
|
-
conventions = detectProjectConventions(args.cwd);
|
|
1155
|
-
} catch (err) {
|
|
1156
|
-
args.dbg?.(`project_snapshot: convention detection failed: ${err}`);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
const snapshot = buildProjectSnapshotFromRuntime({
|
|
1160
|
-
...args,
|
|
1161
|
-
startupScan: args.startupScan ?? existing?.startupScan,
|
|
1162
|
-
languageProfile: args.languageProfile ?? existing?.languageProfile,
|
|
1163
|
-
conventions
|
|
1164
|
-
});
|
|
1165
|
-
if (existing) {
|
|
1166
|
-
snapshot.files = existing.files ?? {};
|
|
1167
|
-
snapshot.symbols = existing.symbols ?? {};
|
|
1168
|
-
snapshot.reverseDeps = existing.reverseDeps ?? {};
|
|
1169
|
-
if (!snapshot.wordIndex && existing.wordIndex && existing.seq === snapshot.seq) {
|
|
1170
|
-
snapshot.wordIndex = existing.wordIndex;
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
saveProjectSnapshot(args.cwd, snapshot);
|
|
1174
|
-
args.dbg?.(`project_snapshot: saved seq=${snapshot.seq} exports=${snapshot.cachedExports.length}`);
|
|
1175
|
-
} catch (err) {
|
|
1176
|
-
args.dbg?.(`project_snapshot: save failed: ${err}`);
|
|
1177
|
-
}
|
|
1178
|
-
}
|