pi-lens 4.1.2 → 4.1.4
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/CHANGELOG.md +1308 -0
- package/README.md +3 -0
- package/config/biome/core.jsonc +11 -2
- package/config/dependency-cruiser-eager-allowlist.json +91 -0
- package/dist/clients/actionable-warnings-logger.js +18 -3
- package/dist/clients/actionable-warnings.js +927 -80
- package/dist/clients/agent-behavior-client.js +13 -4
- package/dist/clients/ast-grep-client.js +136 -9
- package/dist/clients/ast-grep-rule-manager.js +60 -5
- package/dist/clients/ast-grep-tool-logger.js +2 -2
- package/dist/clients/availability-probe-flight.js +12 -0
- package/dist/clients/bash-file-access.js +1 -3
- package/dist/clients/biome-client.js +16 -2
- package/dist/clients/blocker-freshness.js +34 -0
- package/dist/clients/bootstrap.js +509 -73
- package/dist/clients/bounded-cache.js +152 -12
- package/dist/clients/bounded-telemetry.js +115 -23
- package/dist/clients/build-identity.js +95 -0
- package/dist/clients/bundled-resource-health.js +113 -0
- package/dist/clients/bus-events-logger.js +2 -2
- package/dist/clients/bus-publish.js +3 -0
- package/dist/clients/cache/rule-cache.js +33 -5
- package/dist/clients/cache-manager.js +105 -6
- package/dist/clients/cache-observability.js +46 -19
- package/dist/clients/cargo-manifest.js +422 -0
- package/dist/clients/cascade-logger.js +17 -3
- package/dist/clients/code-quality-warnings.js +13 -3
- package/dist/clients/complexity-client.js +16 -5
- package/dist/clients/config-core/deny.js +221 -0
- package/dist/clients/config-core/index.js +47 -0
- package/dist/clients/config-core/merge.js +357 -0
- package/dist/clients/config-core/normalize.js +340 -0
- package/dist/clients/config-core/process-spec.js +248 -0
- package/dist/clients/config-core/provenance.js +171 -0
- package/dist/clients/config-core/records.js +218 -0
- package/dist/clients/config-core/resolve.js +125 -0
- package/dist/clients/config-core/safe-object.js +78 -0
- package/dist/clients/config-core/schema.js +167 -0
- package/dist/clients/config-diagnostic-codes.js +281 -0
- package/dist/clients/config-locations.js +160 -0
- package/dist/clients/config-resolve.js +789 -0
- package/dist/clients/config-schema.js +197 -0
- package/dist/clients/config-warn.js +407 -0
- package/dist/clients/dead-code-client.js +33 -25
- package/dist/clients/dead-code-logger.js +2 -2
- package/dist/clients/deadline-utils.js +178 -0
- package/dist/clients/debug-handles.js +2 -2
- package/dist/clients/debug-heap.js +3 -3
- package/dist/clients/deferred-lsp-work.js +106 -0
- package/dist/clients/degradation-ledger.js +166 -8
- package/dist/clients/demoted-finding-render.js +14 -0
- package/dist/clients/dependency-checker.js +28 -22
- package/dist/clients/deps/minimatch.js +1 -1
- package/dist/clients/diagnostic-line-freshness.js +12 -9
- package/dist/clients/diagnostic-logger.js +14 -4
- package/dist/clients/dispatch/collect-later-tier.js +39 -0
- package/dist/clients/dispatch/dispatcher.js +304 -19
- package/dist/clients/dispatch/fact-store.js +328 -9
- package/dist/clients/dispatch/integration.js +214 -107
- package/dist/clients/dispatch/pending-runner-findings.js +87 -0
- package/dist/clients/dispatch/plan.js +21 -5
- package/dist/clients/dispatch/runners/actionlint.js +0 -1
- package/dist/clients/dispatch/runners/ast-grep-napi.js +550 -77
- package/dist/clients/dispatch/runners/biome-check.js +0 -1
- package/dist/clients/dispatch/runners/cpp-check.js +0 -1
- package/dist/clients/dispatch/runners/credo.js +0 -1
- package/dist/clients/dispatch/runners/cue-vet.js +0 -1
- package/dist/clients/dispatch/runners/dart-analyze.js +0 -1
- package/dist/clients/dispatch/runners/detekt.js +0 -1
- package/dist/clients/dispatch/runners/dotnet-build.js +0 -1
- package/dist/clients/dispatch/runners/elixir-check.js +0 -1
- package/dist/clients/dispatch/runners/eslint.js +5 -2
- package/dist/clients/dispatch/runners/fact-rules.js +0 -1
- package/dist/clients/dispatch/runners/fish-indent.js +0 -1
- package/dist/clients/dispatch/runners/gleam-check.js +0 -1
- package/dist/clients/dispatch/runners/go-vet.js +1 -3
- package/dist/clients/dispatch/runners/golangci-lint.js +0 -1
- package/dist/clients/dispatch/runners/hadolint.js +0 -1
- package/dist/clients/dispatch/runners/helm-lint.js +16 -4
- package/dist/clients/dispatch/runners/helm-render.js +54 -10
- package/dist/clients/dispatch/runners/htmlhint.js +0 -1
- package/dist/clients/dispatch/runners/index.js +1 -3
- package/dist/clients/dispatch/runners/javac.js +0 -1
- package/dist/clients/dispatch/runners/ktlint.js +0 -1
- package/dist/clients/dispatch/runners/lsp.js +37 -2
- package/dist/clients/dispatch/runners/markdownlint.js +4 -2
- package/dist/clients/dispatch/runners/mypy.js +0 -1
- package/dist/clients/dispatch/runners/oxlint.js +24 -22
- package/dist/clients/dispatch/runners/php-lint.js +0 -1
- package/dist/clients/dispatch/runners/phpstan.js +0 -1
- package/dist/clients/dispatch/runners/prisma-validate.js +0 -1
- package/dist/clients/dispatch/runners/psscriptanalyzer.js +4 -1
- package/dist/clients/dispatch/runners/pyright.js +7 -4
- package/dist/clients/dispatch/runners/rubocop.js +0 -1
- package/dist/clients/dispatch/runners/ruff.js +0 -1
- package/dist/clients/dispatch/runners/rust-clippy.js +9 -6
- package/dist/clients/dispatch/runners/shellcheck.js +0 -1
- package/dist/clients/dispatch/runners/shfmt.js +0 -1
- package/dist/clients/dispatch/runners/spellcheck.js +0 -1
- package/dist/clients/dispatch/runners/spotbugs.js +0 -1
- package/dist/clients/dispatch/runners/sqlfluff.js +0 -1
- package/dist/clients/dispatch/runners/stylelint.js +0 -1
- package/dist/clients/dispatch/runners/swiftlint.js +0 -1
- package/dist/clients/dispatch/runners/taplo.js +0 -1
- package/dist/clients/dispatch/runners/terragrunt.js +0 -1
- package/dist/clients/dispatch/runners/tflint.js +0 -1
- package/dist/clients/dispatch/runners/tree-sitter.js +0 -1
- package/dist/clients/dispatch/runners/trivy-config.js +0 -1
- package/dist/clients/dispatch/runners/utils/availability-policy.js +3 -0
- package/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +3 -4
- package/dist/clients/dispatch/runners/utils/runner-helpers.js +270 -105
- package/dist/clients/dispatch/runners/utils/spawn-outcome.js +4 -0
- package/dist/clients/dispatch/runners/utils/tool-failure.js +19 -7
- package/dist/clients/dispatch/runners/utils/toolchain-availability.js +89 -26
- package/dist/clients/dispatch/runners/vale.js +0 -1
- package/dist/clients/dispatch/runners/yaml-rule-parser.js +51 -17
- package/dist/clients/dispatch/runners/yamllint.js +0 -1
- package/dist/clients/dispatch/runners/zig-check.js +0 -1
- package/dist/clients/disposition-logger.js +3 -3
- package/dist/clients/effective-config.js +403 -0
- package/dist/clients/error-class.js +23 -0
- package/dist/clients/event-loop-hold.js +274 -0
- package/dist/clients/event-loop-monitor.js +66 -1
- package/dist/clients/extension-log.js +2 -2
- package/dist/clients/feature-hints.js +2 -1
- package/dist/clients/file-time.js +6 -1
- package/dist/clients/file-utils.js +266 -13
- package/dist/clients/finding-delivery-gate.js +55 -13
- package/dist/clients/format-service.js +6 -1
- package/dist/clients/formatters.js +303 -104
- package/dist/clients/freshness-cadence.js +17 -0
- package/dist/clients/generated-artifacts.js +114 -19
- package/dist/clients/generation-guard.js +4 -9
- package/dist/clients/git-guard.js +198 -48
- package/dist/clients/git-tracked-ignore.js +32 -1
- package/dist/clients/go-client.js +39 -0
- package/dist/clients/govulncheck-client.js +5 -1
- package/dist/clients/gradle-ktfmt-style.js +252 -0
- package/dist/clients/gzip-stage-write.js +7 -0
- package/dist/clients/hashline-anchor.js +424 -0
- package/dist/clients/hook-budgets.js +76 -0
- package/dist/clients/host-edit-normalize.js +5 -2
- package/dist/clients/host-ports.js +1 -1
- package/dist/clients/installer/index.js +200 -84
- package/dist/clients/installer/managed-tool-refresh.js +3 -1
- package/dist/clients/instance-reaper.js +108 -243
- package/dist/clients/instance-registry-lock.js +145 -0
- package/dist/clients/instance-registry.js +435 -122
- package/dist/clients/jscpd-client.js +6 -1
- package/dist/clients/language-profile.js +4 -2
- package/dist/clients/language-registry.js +595 -0
- package/dist/clients/latency-logger.js +179 -3
- package/dist/clients/ledger-bounds.js +13 -0
- package/dist/clients/lens-config.js +141 -30
- package/dist/clients/lens-engine.js +30 -37
- package/dist/clients/lens-flag-registry.js +67 -6
- package/dist/clients/lens-map.js +3 -1
- package/dist/clients/log-cleanup.js +2 -2
- package/dist/clients/lsp/aggregation.js +3 -1
- package/dist/clients/lsp/cascade-tier.js +4 -0
- package/dist/clients/lsp/client.js +672 -49
- package/dist/clients/lsp/config.js +504 -156
- package/dist/clients/lsp/diagnostic-binding.js +10 -5
- package/dist/clients/lsp/edits.js +15 -2
- package/dist/clients/lsp/index.js +1179 -247
- package/dist/clients/lsp/jvm-runtime.js +5 -0
- package/dist/clients/lsp/language.js +18 -169
- package/dist/clients/lsp/launch.js +38 -9
- package/dist/clients/lsp/pending-aux-coverage.js +113 -12
- package/dist/clients/lsp/server.js +426 -160
- package/dist/clients/lsp/session-roots.js +192 -0
- package/dist/clients/lsp/spawn-history.js +2 -7
- package/dist/clients/lsp/tsserver-sync.js +9 -2
- package/dist/clients/lsp/workspace-diagnostics-cache.js +17 -7
- package/dist/clients/lsp/workspace-sweep-hold.js +32 -23
- package/dist/clients/lsp-mutation.js +179 -23
- package/dist/clients/map-with-concurrency.js +36 -0
- package/dist/clients/mcp/analyze.js +45 -10
- package/dist/clients/mcp/session.js +19 -17
- package/dist/clients/memory-sampler.js +28 -1
- package/dist/clients/message-end-attribution.js +30 -0
- package/dist/clients/metrics-history.js +21 -4
- package/dist/clients/middle-man-analysis.js +2 -4
- package/dist/clients/module-report.js +20 -45
- package/dist/clients/mutating-tool.js +651 -0
- package/dist/clients/mutation-attribution.js +368 -0
- package/dist/clients/mutation-bridge.js +240 -0
- package/dist/clients/ndjson-logger.js +247 -20
- package/dist/clients/observed-mutation-sources.js +101 -0
- package/dist/clients/observed-mutation.js +1215 -0
- package/dist/clients/opaque-mutation-scan.js +300 -40
- package/dist/clients/opengrep-config.js +4 -0
- package/dist/clients/package-manager.js +201 -44
- package/dist/clients/partial-edit-apply.js +359 -80
- package/dist/clients/path-attribution-telemetry.js +23 -7
- package/dist/clients/path-keyed-map.js +35 -3
- package/dist/clients/path-utils.js +460 -13
- package/dist/clients/persist-debounce.js +8 -1
- package/dist/clients/php-cs-fixer-config.js +114 -0
- package/dist/clients/pipeline.js +77 -24
- package/dist/clients/probe-home-state.js +228 -0
- package/dist/clients/process-bridge.js +66 -0
- package/dist/clients/process-singletons.js +210 -0
- package/dist/clients/process-snapshot.js +68 -0
- package/dist/clients/project-diagnostics/fresh-fetch.js +4 -3
- package/dist/clients/project-diagnostics/runner-adapters/madge.js +2 -1
- package/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +27 -3
- package/dist/clients/project-diagnostics/scanner.js +61 -24
- package/dist/clients/project-lens-config.js +393 -122
- package/dist/clients/project-snapshot.js +85 -35
- package/dist/clients/python-environment.js +217 -0
- package/dist/clients/python-provenance.js +639 -0
- package/dist/clients/quiet-window.js +6 -1
- package/dist/clients/read-bridge.js +13 -21
- package/dist/clients/read-expansion.js +9 -46
- package/dist/clients/read-guard-logger.js +39 -6
- package/dist/clients/read-guard-tool-lines.js +364 -212
- package/dist/clients/read-guard.js +95 -7
- package/dist/clients/recent-touches.js +17 -5
- package/dist/clients/resource-sampler.js +195 -96
- package/dist/clients/review-graph/builder.js +752 -132
- package/dist/clients/review-graph/service.js +55 -3
- package/dist/clients/review-graph/shared-extraction-ir.js +7 -15
- package/dist/clients/review-graph/tsconfig-paths.js +5 -1
- package/dist/clients/review-graph/workspace-modules.js +10 -74
- package/dist/clients/review-graph-logger.js +30 -4
- package/dist/clients/runtime-agent-end.js +18 -2
- package/dist/clients/runtime-context.js +49 -16
- package/dist/clients/runtime-coordinator.js +93 -6
- package/dist/clients/runtime-session.js +169 -34
- package/dist/clients/runtime-tool-call.js +183 -35
- package/dist/clients/runtime-tool-result.js +894 -241
- package/dist/clients/runtime-turn.js +1264 -74
- package/dist/clients/rust-client.js +31 -0
- package/dist/clients/safe-spawn.js +191 -28
- package/dist/clients/sanitize.js +7 -1
- package/dist/clients/scratch-tree-policy.js +1 -3
- package/dist/clients/security-scan-client.js +51 -17
- package/dist/clients/session-lifecycle.js +238 -42
- package/dist/clients/session-start-observability.js +79 -0
- package/dist/clients/sessionstart-logger.js +12 -3
- package/dist/clients/sg-runner.js +27 -15
- package/dist/clients/sgconfig.js +6 -1
- package/dist/clients/shared-checkout-guard.js +338 -0
- package/dist/clients/skills-resolver.js +105 -0
- package/dist/clients/smells-rollup.js +2 -2
- package/dist/clients/spawn-output-cap.js +37 -0
- package/dist/clients/spawn-timeout-cooldown.js +15 -1
- package/dist/clients/startup-scan.js +6 -7
- package/dist/clients/startup-timing.js +69 -4
- package/dist/clients/string-utils.js +33 -0
- package/dist/clients/subagent-mode.js +17 -4
- package/dist/clients/test-runner-client.js +586 -118
- package/dist/clients/test-runner-delivery.js +239 -0
- package/dist/clients/tool-definition.js +41 -1
- package/dist/clients/tool-policy.js +92 -22
- package/dist/clients/tree-sitter-cache.js +40 -40
- package/dist/clients/tree-sitter-client.js +97 -53
- package/dist/clients/tree-sitter-logger.js +19 -3
- package/dist/clients/tree-sitter-query-loader.js +81 -1
- package/dist/clients/tree-sitter-shared.js +51 -46
- package/dist/clients/tree-sitter-symbol-extractor.js +28 -0
- package/dist/clients/typos-config.js +5 -0
- package/dist/clients/user-notify.js +6 -2
- package/dist/clients/warm-attach.js +8 -10
- package/dist/clients/widget-state.js +191 -26
- package/dist/clients/word-index-logger.js +15 -3
- package/dist/clients/word-index-store.js +463 -0
- package/dist/clients/word-index.js +815 -125
- package/dist/clients/workspace-topology.js +25 -1
- package/dist/clients/zizmor-config.js +29 -6
- package/dist/index.js +68577 -53950
- package/dist/mcp/analyze-cli.js +3 -1
- package/dist/mcp/build-staleness.js +8 -7
- package/dist/mcp/cli.js +3 -1
- package/dist/mcp/server.js +133 -6
- package/dist/scripts/lib/process-scan.mjs +583 -0
- package/dist/scripts/lib/skills-predicate.mjs +129 -0
- package/dist/tools/effective-config.js +89 -0
- package/dist/tools/lens-diagnostics.js +99 -24
- package/dist/tools/lsp-diagnostics.js +81 -85
- package/dist/tools/lsp-navigation.js +40 -17
- package/dist/tools/shared.js +0 -1
- package/docs/agent-guide.md +68 -3
- package/docs/ast-grep_rules_catalog.md +41 -10
- package/docs/astplayground.md +26 -17
- package/docs/configuration.md +222 -0
- package/docs/dependencies.md +3 -3
- package/docs/features.md +44 -5
- package/docs/language-coverage.md +2 -2
- package/docs/pi-lens-fixer.md +25 -0
- package/docs/pi-lens-investigator.md +25 -0
- package/docs/pi-lens-reviewer.md +27 -0
- package/docs/pi-lens-subagent.md +38 -0
- package/docs/pi-lens-warden.md +55 -0
- package/docs/public-api-stability.md +359 -0
- package/docs/release-qa-baseline.md +182 -0
- package/docs/subagent-compat.md +110 -30
- package/docs/tree-sitter_rules_catalog.md +2 -2
- package/package.json +17 -21
- package/rules/ast-grep-rules/rule-tests/c-no-malloc-free-test.yml +20 -0
- package/rules/ast-grep-rules/rule-tests/cpp-no-malloc-free-test.yml +25 -0
- package/rules/ast-grep-rules/rule-tests/cpp-no-printf-test.yml +19 -0
- package/rules/ast-grep-rules/rule-tests/go-no-fmt-println-test.yml +19 -0
- package/rules/ast-grep-rules/rule-tests/go-no-panic-in-lib-test.yml +17 -0
- package/rules/ast-grep-rules/rule-tests/go-no-underscore-func-name-test.yml +18 -0
- package/rules/ast-grep-rules/rule-tests/go-prefer-errors-is-test.yml +15 -0
- package/rules/ast-grep-rules/rule-tests/go-prefer-string-builder-test.yml +21 -0
- package/rules/ast-grep-rules/rule-tests/hyphenated-svg-attribute-test.yml +11 -0
- package/rules/ast-grep-rules/rule-tests/kotlin-no-lateinit-test.yml +17 -0
- package/rules/ast-grep-rules/rule-tests/kotlin-no-nullable-boolean-test.yml +15 -0
- package/rules/ast-grep-rules/rule-tests/kotlin-no-println-test.yml +19 -0
- package/rules/ast-grep-rules/rule-tests/kotlin-no-unnecessary-let-test.yml +7 -0
- package/rules/ast-grep-rules/rule-tests/kotlin-no-unsafe-cast-test.yml +7 -0
- package/rules/ast-grep-rules/rule-tests/kotlin-no-var-test.yml +7 -0
- package/rules/ast-grep-rules/rule-tests/kotlin-prefer-data-class-test.yml +25 -0
- package/rules/ast-grep-rules/rule-tests/kotlin-prefer-is-empty-test.yml +11 -0
- package/rules/ast-grep-rules/rule-tests/no-important-test.yml +21 -0
- package/rules/ast-grep-rules/rule-tests/no-raw-types-test.yml +30 -0
- package/rules/ast-grep-rules/rule-tests/no-string-concat-in-loop-test.yml +100 -0
- package/rules/ast-grep-rules/rule-tests/no-system-out-println-test.yml +7 -0
- package/rules/ast-grep-rules/rule-tests/prefer-string-is-empty-test.yml +7 -0
- package/rules/ast-grep-rules/rule-tests/python-optional-type-test.yml +9 -0
- package/rules/ast-grep-rules/rule-tests/reducible-list-comprehension-test.yml +11 -0
- package/rules/ast-grep-rules/rule-tests/ruby-symbol-to-proc-candidate-test.yml +10 -0
- package/rules/ast-grep-rules/rule-tests/rust-no-chars-enumerate-test.yml +7 -0
- package/rules/ast-grep-rules/rules/c-no-malloc-free.yml +39 -0
- package/rules/ast-grep-rules/rules/cpp-no-malloc-free.yml +45 -0
- package/rules/ast-grep-rules/rules/cpp-no-printf.yml +41 -0
- package/rules/ast-grep-rules/rules/go-no-fmt-println.yml +43 -0
- package/rules/ast-grep-rules/rules/go-no-panic-in-lib.yml +41 -0
- package/rules/ast-grep-rules/rules/go-no-underscore-func-name.yml +35 -0
- package/rules/ast-grep-rules/rules/go-prefer-errors-is.yml +40 -0
- package/rules/ast-grep-rules/rules/go-prefer-string-builder.yml +43 -0
- package/rules/ast-grep-rules/rules/hyphenated-svg-attribute.yml +32 -0
- package/rules/ast-grep-rules/rules/kotlin-no-lateinit.yml +37 -0
- package/rules/ast-grep-rules/rules/kotlin-no-nullable-boolean.yml +33 -0
- package/rules/ast-grep-rules/rules/kotlin-no-println.yml +42 -0
- package/rules/ast-grep-rules/rules/kotlin-no-unnecessary-let.yml +28 -0
- package/rules/ast-grep-rules/rules/kotlin-no-unsafe-cast.yml +28 -0
- package/rules/ast-grep-rules/rules/kotlin-no-var.yml +35 -0
- package/rules/ast-grep-rules/rules/kotlin-prefer-data-class.yml +66 -0
- package/rules/ast-grep-rules/rules/kotlin-prefer-is-empty.yml +35 -0
- package/rules/ast-grep-rules/rules/no-important.yml +21 -0
- package/rules/ast-grep-rules/rules/no-raw-types.yml +33 -0
- package/rules/ast-grep-rules/rules/no-string-concat-in-loop.yml +90 -0
- package/rules/ast-grep-rules/rules/no-system-out-println.yml +16 -0
- package/rules/ast-grep-rules/rules/prefer-string-is-empty.yml +11 -0
- package/rules/ast-grep-rules/rules/python-optional-type.yml +22 -0
- package/rules/ast-grep-rules/rules/reducible-list-comprehension.yml +29 -0
- package/rules/ast-grep-rules/rules/ruby-symbol-to-proc-candidate.yml +25 -0
- package/rules/ast-grep-rules/rules/rust-no-chars-enumerate.yml +19 -0
- package/rules/tree-sitter-queries/python/python-cross-language-method.yml +3 -3
- package/rules/tree-sitter-queries/python/python-hallucinated-import.yml +2 -2
- package/rules/tree-sitter-queries/python/python-sql-injection.yml +12 -2
- package/scripts/analyze-pi-lens-logs.mjs +192 -1
- package/scripts/install-selftest.mjs +58 -2
- package/scripts/lib/skills-predicate.mjs +129 -0
- package/scripts/rpc-load-check.mjs +3 -1
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
* `_turnSummaryEmitCtx`), so flag changes take effect immediately.
|
|
58
58
|
*/
|
|
59
59
|
/** Stable Symbol key — identical across module reloads in the same process. */
|
|
60
|
+
import { registerProcessBridge } from "./process-bridge.js";
|
|
60
61
|
import { captureReadContentBinding, } from "./read-guard.js";
|
|
61
62
|
export const READ_BRIDGE_KEY = Symbol.for("pi-lens:read-bridge");
|
|
62
63
|
/**
|
|
@@ -96,15 +97,12 @@ function isValidEntry(entry) {
|
|
|
96
97
|
}
|
|
97
98
|
/**
|
|
98
99
|
* Mount the bridge singleton. Call once from inside the extension factory
|
|
99
|
-
* (protected by the `_readBridgeRegistered` module-level flag).
|
|
100
|
-
*
|
|
100
|
+
* (protected by the `_readBridgeRegistered` module-level flag). Subsequent
|
|
101
|
+
* calls are no-ops (first-wins, `clients/process-bridge.ts` owns the mount
|
|
102
|
+
* body — see that module's header, #2437).
|
|
101
103
|
*/
|
|
102
104
|
export function registerReadBridge(deps) {
|
|
103
|
-
|
|
104
|
-
// on a redundant defineProperty attempt.
|
|
105
|
-
if (READ_BRIDGE_KEY in globalThis)
|
|
106
|
-
return;
|
|
107
|
-
const bridge = Object.freeze({
|
|
105
|
+
registerProcessBridge(READ_BRIDGE_KEY, () => ({
|
|
108
106
|
version: 1,
|
|
109
107
|
recordRead(entry) {
|
|
110
108
|
// Validate the payload before doing anything else — this catches
|
|
@@ -114,8 +112,9 @@ export function registerReadBridge(deps) {
|
|
|
114
112
|
if (!deps.isRecordable(entry.filePath))
|
|
115
113
|
return;
|
|
116
114
|
const offset = entry.requestedOffset;
|
|
117
|
-
// When no limit is given treat the whole file as covered — the
|
|
118
|
-
// clips to the actual line count via its own file-length
|
|
115
|
+
// When no limit is given treat the whole file as covered — the
|
|
116
|
+
// guard clips to the actual line count via its own file-length
|
|
117
|
+
// probe.
|
|
119
118
|
const limit = entry.requestedLimit ?? Number.MAX_SAFE_INTEGER;
|
|
120
119
|
const contentBinding = captureReadContentBinding(entry.filePath, offset, limit);
|
|
121
120
|
deps.getReadGuard().recordRead({
|
|
@@ -127,21 +126,14 @@ export function registerReadBridge(deps) {
|
|
|
127
126
|
expandedByLsp: false,
|
|
128
127
|
turnIndex: deps.getTurnIndex(),
|
|
129
128
|
writeIndex: deps.peekWriteIndex(),
|
|
130
|
-
// Stamp the timestamp here, matching exactly how the internal
|
|
131
|
-
// path works (runtime-tool-call.ts always uses Date.now()).
|
|
129
|
+
// Stamp the timestamp here, matching exactly how the internal
|
|
130
|
+
// read path works (runtime-tool-call.ts always uses Date.now()).
|
|
132
131
|
timestamp: Date.now(),
|
|
133
|
-
// Provenance: identifies this record as bridge-sourced in
|
|
132
|
+
// Provenance: identifies this record as bridge-sourced in
|
|
133
|
+
// read-guard.log.
|
|
134
134
|
source: `bridge:${entry.consumer ?? "unknown"}`,
|
|
135
135
|
...(contentBinding !== undefined && { contentBinding }),
|
|
136
136
|
});
|
|
137
137
|
},
|
|
138
|
-
});
|
|
139
|
-
// Register as non-writable, non-configurable so no subsequent code can
|
|
140
|
-
// silently overwrite the bridge (first-wins is the contract).
|
|
141
|
-
Object.defineProperty(globalThis, READ_BRIDGE_KEY, {
|
|
142
|
-
value: bridge,
|
|
143
|
-
writable: false,
|
|
144
|
-
configurable: false,
|
|
145
|
-
enumerable: false,
|
|
146
|
-
});
|
|
138
|
+
}));
|
|
147
139
|
}
|
|
@@ -7,60 +7,23 @@
|
|
|
7
7
|
* within the symbol pass without requiring the agent to have read every line.
|
|
8
8
|
*/
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
|
+
import { extname } from "node:path";
|
|
10
11
|
import { withBudget } from "./deadline-utils.js";
|
|
12
|
+
import { EXTENSION_TO_GRAMMAR } from "./language-registry.js";
|
|
11
13
|
/** Only expand reads smaller than this (lines). Larger reads don't benefit. */
|
|
12
14
|
export const EXPANSION_LIMIT_LINES = 100;
|
|
13
15
|
/** Don't expand to a symbol larger than this. */
|
|
14
16
|
const EXPANDED_SIZE_CAP_LINES = 300;
|
|
15
17
|
/** Async budget for tree-sitter parse + walk. */
|
|
16
18
|
export const EXPANSION_BUDGET_MS = 200;
|
|
17
|
-
/** File extensions we can parse — mirrors tree-sitter runner. */
|
|
18
|
-
const EXT_TO_LANG = {
|
|
19
|
-
".ts": "typescript",
|
|
20
|
-
".mts": "typescript",
|
|
21
|
-
".cts": "typescript",
|
|
22
|
-
".tsx": "tsx",
|
|
23
|
-
".js": "javascript",
|
|
24
|
-
".mjs": "javascript",
|
|
25
|
-
".cjs": "javascript",
|
|
26
|
-
".jsx": "javascript",
|
|
27
|
-
".py": "python",
|
|
28
|
-
".go": "go",
|
|
29
|
-
".rs": "rust",
|
|
30
|
-
".rb": "ruby",
|
|
31
|
-
".java": "java",
|
|
32
|
-
".kt": "kotlin",
|
|
33
|
-
".kts": "kotlin",
|
|
34
|
-
".dart": "dart",
|
|
35
|
-
".ex": "elixir",
|
|
36
|
-
".exs": "elixir",
|
|
37
|
-
".c": "c",
|
|
38
|
-
".h": "c",
|
|
39
|
-
".cc": "cpp",
|
|
40
|
-
".cpp": "cpp",
|
|
41
|
-
".cxx": "cpp",
|
|
42
|
-
".c++": "cpp",
|
|
43
|
-
".hh": "cpp",
|
|
44
|
-
".hpp": "cpp",
|
|
45
|
-
".hxx": "cpp",
|
|
46
|
-
".cs": "csharp",
|
|
47
|
-
".php": "php",
|
|
48
|
-
".phtml": "php",
|
|
49
|
-
".swift": "swift",
|
|
50
|
-
".lua": "lua",
|
|
51
|
-
".ml": "ocaml",
|
|
52
|
-
".mli": "ocaml",
|
|
53
|
-
".zig": "zig",
|
|
54
|
-
".sh": "bash",
|
|
55
|
-
".bash": "bash",
|
|
56
|
-
};
|
|
57
19
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* supported language instead of a hardcoded subset (#262).
|
|
20
|
+
* The grammar this module would parse `filePath` with, or undefined when read
|
|
21
|
+
* expansion does not understand the extension. Exported so the
|
|
22
|
+
* language-identity golden snapshot can record this consumer's answer.
|
|
62
23
|
*/
|
|
63
|
-
export
|
|
24
|
+
export function readExpansionLanguage(filePath) {
|
|
25
|
+
return EXTENSION_TO_GRAMMAR[extname(filePath).toLowerCase()];
|
|
26
|
+
}
|
|
64
27
|
/** AST node types considered "enclosing symbols" for coverage purposes. */
|
|
65
28
|
const ENCLOSING_TYPES = {
|
|
66
29
|
typescript: [
|
|
@@ -241,7 +204,7 @@ export async function tryExpandRead(filePath, requestedOffset, requestedLimit, t
|
|
|
241
204
|
return undefined;
|
|
242
205
|
return { ...result, durationMs: Date.now() - startedAt };
|
|
243
206
|
}
|
|
244
|
-
const languageId =
|
|
207
|
+
const languageId = readExpansionLanguage(filePath);
|
|
245
208
|
if (!languageId)
|
|
246
209
|
return undefined;
|
|
247
210
|
const enclosingTypes = ENCLOSING_TYPES[languageId];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { isTestMode } from "./env-utils.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getGlobalPiLensLogDir } from "./probe-home-state.js";
|
|
4
4
|
import { createNdjsonLogger } from "./ndjson-logger.js";
|
|
5
|
-
|
|
5
|
+
import { normalizeFilePath } from "./path-utils.js";
|
|
6
|
+
const READ_GUARD_LOG_DIR = getGlobalPiLensLogDir();
|
|
6
7
|
const READ_GUARD_LOG_FILE = path.join(READ_GUARD_LOG_DIR, "read-guard.log");
|
|
7
8
|
const READ_GUARD_LOG_BACKUP_FILE = path.join(READ_GUARD_LOG_DIR, "read-guard.log.1");
|
|
8
9
|
const MAX_LOG_BYTES = Math.max(128 * 1024, Number.parseInt(process.env.PI_LENS_READ_GUARD_MAX_BYTES ?? "1048576", 10) ||
|
|
@@ -67,11 +68,13 @@ export function createReadGuardEditBatchSummary(args) {
|
|
|
67
68
|
const resolvedSource = validIndexes(args.resolvedIndexes ?? []);
|
|
68
69
|
const rejectedSource = (args.rejectedReasons ?? []).filter((entry) => Number.isInteger(entry.index) && entry.index >= 0);
|
|
69
70
|
const appliedSource = validIndexes(args.appliedIndexes ?? []);
|
|
71
|
+
const alreadyAppliedSource = validIndexes(args.alreadyAppliedIndexes ?? []);
|
|
70
72
|
const requestedIndexes = boundedEditIndexes(requestedSource);
|
|
71
73
|
const resolvedIndexes = boundedEditIndexes(resolvedSource);
|
|
72
74
|
const rejectedReasons = rejectedSource.slice(0, MAX_EDIT_BATCH_ITEMS);
|
|
73
75
|
const rejectedIndexes = boundedEditIndexes(rejectedSource.map((entry) => entry.index));
|
|
74
76
|
const appliedIndexes = boundedEditIndexes(appliedSource);
|
|
77
|
+
const alreadyAppliedIndexes = boundedEditIndexes(alreadyAppliedSource);
|
|
75
78
|
const participantSource = (args.participantIds ?? []).filter((id) => typeof id === "string" && id.length > 0);
|
|
76
79
|
const participantIds = [...new Set(participantSource)].slice(0, MAX_EDIT_BATCH_ITEMS);
|
|
77
80
|
const commitStatus = args.commitStatus ?? "not_attempted";
|
|
@@ -98,6 +101,9 @@ export function createReadGuardEditBatchSummary(args) {
|
|
|
98
101
|
appliedCount: appliedSource.length,
|
|
99
102
|
appliedTotal: args.appliedTotal ?? appliedSource.length,
|
|
100
103
|
appliedIndexes,
|
|
104
|
+
alreadyAppliedCount: alreadyAppliedSource.length,
|
|
105
|
+
alreadyAppliedTotal: args.alreadyAppliedTotal ?? alreadyAppliedSource.length,
|
|
106
|
+
alreadyAppliedIndexes,
|
|
101
107
|
participantIds,
|
|
102
108
|
participantTotal: args.participantTotal ?? participantSource.length,
|
|
103
109
|
participantIdsTruncated: (args.participantTotal ?? participantSource.length) >
|
|
@@ -106,7 +112,9 @@ export function createReadGuardEditBatchSummary(args) {
|
|
|
106
112
|
requestedIndexes.length ||
|
|
107
113
|
(args.resolvedTotal ?? resolvedSource.length) > resolvedIndexes.length ||
|
|
108
114
|
(args.rejectedTotal ?? rejectedSource.length) > rejectedIndexes.length ||
|
|
109
|
-
(args.appliedTotal ?? appliedSource.length) > appliedIndexes.length
|
|
115
|
+
(args.appliedTotal ?? appliedSource.length) > appliedIndexes.length ||
|
|
116
|
+
(args.alreadyAppliedTotal ?? alreadyAppliedSource.length) >
|
|
117
|
+
alreadyAppliedIndexes.length,
|
|
110
118
|
commitStatus,
|
|
111
119
|
postEditStatus,
|
|
112
120
|
terminalStatus,
|
|
@@ -132,6 +140,10 @@ export function shouldLogEvent(event) {
|
|
|
132
140
|
event === "edit_preflight_blocked" ||
|
|
133
141
|
event === "edit_partial_apply" ||
|
|
134
142
|
event === "edit_partial_apply_skipped" ||
|
|
143
|
+
// #2402: pre-write batch rejections and recognized exact retries are the
|
|
144
|
+
// two new partial-apply outcomes; each is rare by construction.
|
|
145
|
+
event === "edit_partial_apply_rejected" ||
|
|
146
|
+
event === "edit_already_applied_retry" ||
|
|
135
147
|
event === "edit_post_edit_pipeline_failed" ||
|
|
136
148
|
event === "edit_batch_summary" ||
|
|
137
149
|
event === "edit_batch_summary_overflow" ||
|
|
@@ -140,7 +152,18 @@ export function shouldLogEvent(event) {
|
|
|
140
152
|
// READ_GUARD_MAX_RECORDS_PER_FILE overflow triggers one), so this trim
|
|
141
153
|
// record bypasses the per-read verbosity gate — a live eviction
|
|
142
154
|
// regression must be visible without PI_LENS_READ_GUARD_VERBOSE=1.
|
|
143
|
-
event === "read_cap_trimmed"
|
|
155
|
+
event === "read_cap_trimmed" ||
|
|
156
|
+
// #1918: the record-cap trim's population siblings — whole-file
|
|
157
|
+
// eviction under real pressure (file cap or an external delete) and
|
|
158
|
+
// the per-file edits-cap trim. Idle-timeout eviction is deliberately
|
|
159
|
+
// EXCLUDED from this event (see read-guard.ts's evictFile doc
|
|
160
|
+
// comment) — it's routine housekeeping, not a fault, and its
|
|
161
|
+
// per-file cardinality is unbounded in a healthy session. Same
|
|
162
|
+
// rarity argument as #1913 for the reasons that DO fire: each is
|
|
163
|
+
// rising-edge gated once per file per session, so always-on
|
|
164
|
+
// visibility costs nothing.
|
|
165
|
+
event === "read_file_evicted" ||
|
|
166
|
+
event === "edits_cap_trimmed");
|
|
144
167
|
}
|
|
145
168
|
const MAX_TELEMETRY_STRING = 512;
|
|
146
169
|
const MAX_TELEMETRY_KEYS = 64;
|
|
@@ -192,7 +215,7 @@ export function logReadGuardEvent(entry) {
|
|
|
192
215
|
return;
|
|
193
216
|
}
|
|
194
217
|
const rawMetadata = entry.correlationId
|
|
195
|
-
? { ...
|
|
218
|
+
? { ...entry.metadata, correlationId: entry.correlationId }
|
|
196
219
|
: entry.metadata;
|
|
197
220
|
const bounded = boundTelemetryValue(rawMetadata, "metadata", 0);
|
|
198
221
|
const metadata = bounded.truncated && bounded.value && typeof bounded.value === "object"
|
|
@@ -205,7 +228,17 @@ export function logReadGuardEvent(entry) {
|
|
|
205
228
|
? bounded.value
|
|
206
229
|
: undefined;
|
|
207
230
|
const { correlationId: _correlationId, ...logEntry } = entry;
|
|
208
|
-
|
|
231
|
+
// #2219 (the #2141 class): `filePath` reaches here from
|
|
232
|
+
// `runtime-tool-result.ts`'s raw `path.resolve()`/`path.isAbsolute()`
|
|
233
|
+
// arithmetic (never `normalizeFilePath`-passed), always a genuine file —
|
|
234
|
+
// this field carries no non-path sentinel. Normalize once at this single
|
|
235
|
+
// emit seam, matching `review-graph-logger.ts`'s `logReviewGraph`.
|
|
236
|
+
writer.log({
|
|
237
|
+
ts: new Date().toISOString(),
|
|
238
|
+
...logEntry,
|
|
239
|
+
filePath: normalizeFilePath(logEntry.filePath),
|
|
240
|
+
metadata,
|
|
241
|
+
});
|
|
209
242
|
}
|
|
210
243
|
export function getReadGuardLogPath() {
|
|
211
244
|
return READ_GUARD_LOG_FILE;
|