code-auditor-mcp 4.1.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +374 -0
- package/README.md +4 -4
- package/configs/hhra-compat.json +0 -8
- package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.d.ts +1 -1
- package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.d.ts.map +1 -1
- package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.js +7 -1
- package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.js.map +1 -1
- package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.d.ts +2 -8
- package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.d.ts.map +1 -1
- package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.js +4 -4
- package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.js.map +1 -1
- package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.d.ts +1 -1
- package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.d.ts.map +1 -1
- package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.js.map +1 -1
- package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.d.ts +2 -2
- package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.d.ts.map +1 -1
- package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.js.map +1 -1
- package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.d.ts +1 -1
- package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.d.ts.map +1 -1
- package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.js.map +1 -1
- package/dist/analyzers/applicability.d.ts +42 -0
- package/dist/analyzers/applicability.d.ts.map +1 -1
- package/dist/analyzers/applicability.js +74 -0
- package/dist/analyzers/applicability.js.map +1 -1
- package/dist/analyzers/cross-language/APIContractAnalyzer.js +18 -24
- package/dist/analyzers/cross-language/APIContractAnalyzer.js.map +1 -1
- package/dist/analyzers/cross-language/DependencyGraphBuilder.d.ts +30 -23
- package/dist/analyzers/cross-language/DependencyGraphBuilder.d.ts.map +1 -1
- package/dist/analyzers/cross-language/DependencyGraphBuilder.js +113 -76
- package/dist/analyzers/cross-language/DependencyGraphBuilder.js.map +1 -1
- package/dist/analyzers/cross-language/SchemaValidator.d.ts +2 -0
- package/dist/analyzers/cross-language/SchemaValidator.d.ts.map +1 -1
- package/dist/analyzers/cross-language/SchemaValidator.js +8 -3
- package/dist/analyzers/cross-language/SchemaValidator.js.map +1 -1
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js +210 -148
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js.map +1 -1
- package/dist/analyzers/documentationAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/documentationAnalyzer.js +23 -28
- package/dist/analyzers/documentationAnalyzer.js.map +1 -1
- package/dist/analyzers/handleIdentification.d.ts +356 -0
- package/dist/analyzers/handleIdentification.d.ts.map +1 -0
- package/dist/analyzers/handleIdentification.js +424 -0
- package/dist/analyzers/handleIdentification.js.map +1 -0
- package/dist/analyzers/manifestStaleness.d.ts +64 -0
- package/dist/analyzers/manifestStaleness.d.ts.map +1 -0
- package/dist/analyzers/manifestStaleness.js +115 -0
- package/dist/analyzers/manifestStaleness.js.map +1 -0
- package/dist/analyzers/orgFilterTiers.d.ts +73 -1
- package/dist/analyzers/orgFilterTiers.d.ts.map +1 -1
- package/dist/analyzers/orgFilterTiers.js +166 -1
- package/dist/analyzers/orgFilterTiers.js.map +1 -1
- package/dist/analyzers/provenance.d.ts +251 -57
- package/dist/analyzers/provenance.d.ts.map +1 -1
- package/dist/analyzers/provenance.js +1109 -429
- package/dist/analyzers/provenance.js.map +1 -1
- package/dist/analyzers/reactAnalyzer.d.ts +2 -0
- package/dist/analyzers/reactAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/reactAnalyzer.js +2 -0
- package/dist/analyzers/reactAnalyzer.js.map +1 -1
- package/dist/analyzers/receiverResolution.d.ts +183 -0
- package/dist/analyzers/receiverResolution.d.ts.map +1 -0
- package/dist/analyzers/receiverResolution.js +540 -0
- package/dist/analyzers/receiverResolution.js.map +1 -0
- package/dist/analyzers/receiverRoot.d.ts +328 -0
- package/dist/analyzers/receiverRoot.d.ts.map +1 -0
- package/dist/analyzers/receiverRoot.js +990 -0
- package/dist/analyzers/receiverRoot.js.map +1 -0
- package/dist/analyzers/ruleRegistry.d.ts +12 -68
- package/dist/analyzers/ruleRegistry.d.ts.map +1 -1
- package/dist/analyzers/ruleRegistry.js +32 -342
- package/dist/analyzers/ruleRegistry.js.map +1 -1
- package/dist/analyzers/ruleTiming.d.ts +10 -0
- package/dist/analyzers/ruleTiming.d.ts.map +1 -1
- package/dist/analyzers/ruleTiming.js +20 -0
- package/dist/analyzers/ruleTiming.js.map +1 -1
- package/dist/analyzers/sqlLiteral.d.ts +76 -0
- package/dist/analyzers/sqlLiteral.d.ts.map +1 -0
- package/dist/analyzers/sqlLiteral.js +419 -0
- package/dist/analyzers/sqlLiteral.js.map +1 -0
- package/dist/analyzers/tsEcosystem.d.ts +115 -0
- package/dist/analyzers/tsEcosystem.d.ts.map +1 -0
- package/dist/analyzers/tsEcosystem.js +231 -0
- package/dist/analyzers/tsEcosystem.js.map +1 -0
- package/dist/analyzers/tsExpressionDescriptor.d.ts +156 -0
- package/dist/analyzers/tsExpressionDescriptor.d.ts.map +1 -0
- package/dist/analyzers/tsExpressionDescriptor.js +374 -0
- package/dist/analyzers/tsExpressionDescriptor.js.map +1 -0
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.d.ts +6 -0
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.js +107 -44
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalDRYAnalyzer.d.ts +1 -12
- package/dist/analyzers/universal/UniversalDRYAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalDRYAnalyzer.js +24 -101
- package/dist/analyzers/universal/UniversalDRYAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts +287 -49
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js +2130 -512
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalDocumentationAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalDocumentationAnalyzer.js +2 -18
- package/dist/analyzers/universal/UniversalDocumentationAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts +0 -33
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js +20 -143
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalSchemaAnalyzer.d.ts +4 -3
- package/dist/analyzers/universal/UniversalSchemaAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalSchemaAnalyzer.js +36 -13
- package/dist/analyzers/universal/UniversalSchemaAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalSecretsAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalSecretsAnalyzer.js +6 -0
- package/dist/analyzers/universal/UniversalSecretsAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalSecurityAnalyzer.d.ts +15 -0
- package/dist/analyzers/universal/UniversalSecurityAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalSecurityAnalyzer.js +25 -0
- package/dist/analyzers/universal/UniversalSecurityAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts +21 -32
- package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalStylesAnalyzer.js +166 -196
- package/dist/analyzers/universal/UniversalStylesAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/functionConcerns.d.ts +3 -0
- package/dist/analyzers/universal/functionConcerns.d.ts.map +1 -1
- package/dist/analyzers/universal/functionConcerns.js +4 -1
- package/dist/analyzers/universal/functionConcerns.js.map +1 -1
- package/dist/analyzers/universal/schema/codeAnalysis.d.ts +310 -69
- package/dist/analyzers/universal/schema/codeAnalysis.d.ts.map +1 -1
- package/dist/analyzers/universal/schema/codeAnalysis.js +709 -383
- package/dist/analyzers/universal/schema/codeAnalysis.js.map +1 -1
- package/dist/analyzers/universal/schema/config.d.ts +3 -14
- package/dist/analyzers/universal/schema/config.d.ts.map +1 -1
- package/dist/analyzers/universal/schema/config.js +3 -16
- package/dist/analyzers/universal/schema/config.js.map +1 -1
- package/dist/analyzers/universal/schema/discovery.d.ts +22 -1
- package/dist/analyzers/universal/schema/discovery.d.ts.map +1 -1
- package/dist/analyzers/universal/schema/discovery.js +36 -20
- package/dist/analyzers/universal/schema/discovery.js.map +1 -1
- package/dist/analyzers/universal/schema/jsonSchema.d.ts.map +1 -1
- package/dist/analyzers/universal/schema/jsonSchema.js +13 -3
- package/dist/analyzers/universal/schema/jsonSchema.js.map +1 -1
- package/dist/analyzers/universal/schema/migrations.d.ts +187 -27
- package/dist/analyzers/universal/schema/migrations.d.ts.map +1 -1
- package/dist/analyzers/universal/schema/migrations.js +443 -186
- package/dist/analyzers/universal/schema/migrations.js.map +1 -1
- package/dist/analyzers/universal/schema/types.d.ts +17 -3
- package/dist/analyzers/universal/schema/types.d.ts.map +1 -1
- package/dist/analyzers/universal/schema/violations.js +1 -1
- package/dist/analyzers/universal/schema/violations.js.map +1 -1
- package/dist/analyzers/universal/styleScale.d.ts +52 -0
- package/dist/analyzers/universal/styleScale.d.ts.map +1 -0
- package/dist/analyzers/universal/styleScale.js +95 -0
- package/dist/analyzers/universal/styleScale.js.map +1 -0
- package/dist/applyDataDirEnv.js +1 -1
- package/dist/applyDataDirEnv.js.map +1 -1
- package/dist/auditRouter.d.ts +26 -30
- package/dist/auditRouter.d.ts.map +1 -1
- package/dist/auditRouter.js +373 -143
- package/dist/auditRouter.js.map +1 -1
- package/dist/auditRunner.d.ts +64 -1
- package/dist/auditRunner.d.ts.map +1 -1
- package/dist/auditRunner.js +1537 -1051
- package/dist/auditRunner.js.map +1 -1
- package/dist/baseline.d.ts +30 -3
- package/dist/baseline.d.ts.map +1 -1
- package/dist/baseline.js +70 -9
- package/dist/baseline.js.map +1 -1
- package/dist/cli.js +997 -812
- package/dist/cli.js.map +1 -1
- package/dist/codeIndex/analyzerConfig.d.ts +60 -0
- package/dist/codeIndex/analyzerConfig.d.ts.map +1 -0
- package/dist/codeIndex/analyzerConfig.js +98 -0
- package/dist/codeIndex/analyzerConfig.js.map +1 -0
- package/dist/codeIndex/auditResults.d.ts +39 -0
- package/dist/codeIndex/auditResults.d.ts.map +1 -0
- package/dist/codeIndex/auditResults.js +99 -0
- package/dist/codeIndex/auditResults.js.map +1 -0
- package/dist/codeIndex/codeMap.d.ts +59 -0
- package/dist/codeIndex/codeMap.d.ts.map +1 -0
- package/dist/codeIndex/codeMap.js +72 -0
- package/dist/codeIndex/codeMap.js.map +1 -0
- package/dist/codeIndex/conventions.d.ts +33 -0
- package/dist/codeIndex/conventions.d.ts.map +1 -0
- package/dist/codeIndex/conventions.js +84 -0
- package/dist/codeIndex/conventions.js.map +1 -0
- package/dist/codeIndex/coverage.d.ts +78 -0
- package/dist/codeIndex/coverage.d.ts.map +1 -0
- package/dist/codeIndex/coverage.js +164 -0
- package/dist/codeIndex/coverage.js.map +1 -0
- package/dist/codeIndex/dependencyGraph.d.ts +97 -0
- package/dist/codeIndex/dependencyGraph.d.ts.map +1 -0
- package/dist/codeIndex/dependencyGraph.js +241 -0
- package/dist/codeIndex/dependencyGraph.js.map +1 -0
- package/dist/codeIndex/functionIndex.d.ts +111 -0
- package/dist/codeIndex/functionIndex.d.ts.map +1 -0
- package/dist/codeIndex/functionIndex.js +306 -0
- package/dist/codeIndex/functionIndex.js.map +1 -0
- package/dist/codeIndex/inferredReceivers.d.ts +32 -0
- package/dist/codeIndex/inferredReceivers.d.ts.map +1 -0
- package/dist/codeIndex/inferredReceivers.js +41 -0
- package/dist/codeIndex/inferredReceivers.js.map +1 -0
- package/dist/codeIndex/meta.d.ts +30 -0
- package/dist/codeIndex/meta.d.ts.map +1 -0
- package/dist/codeIndex/meta.js +37 -0
- package/dist/codeIndex/meta.js.map +1 -0
- package/dist/codeIndex/migrations.d.ts +96 -0
- package/dist/codeIndex/migrations.d.ts.map +1 -0
- package/dist/codeIndex/migrations.js +1302 -0
- package/dist/codeIndex/migrations.js.map +1 -0
- package/dist/codeIndex/projectTasks.d.ts +54 -0
- package/dist/codeIndex/projectTasks.d.ts.map +1 -0
- package/dist/codeIndex/projectTasks.js +81 -0
- package/dist/codeIndex/projectTasks.js.map +1 -0
- package/dist/codeIndex/provenance.d.ts +47 -0
- package/dist/codeIndex/provenance.d.ts.map +1 -0
- package/dist/codeIndex/provenance.js +48 -0
- package/dist/codeIndex/provenance.js.map +1 -0
- package/dist/codeIndex/rawSql.d.ts +54 -0
- package/dist/codeIndex/rawSql.d.ts.map +1 -0
- package/dist/codeIndex/rawSql.js +71 -0
- package/dist/codeIndex/rawSql.js.map +1 -0
- package/dist/codeIndex/schema.d.ts +99 -0
- package/dist/codeIndex/schema.d.ts.map +1 -0
- package/dist/codeIndex/schema.js +174 -0
- package/dist/codeIndex/schema.js.map +1 -0
- package/dist/codeIndex/search.d.ts +40 -0
- package/dist/codeIndex/search.d.ts.map +1 -0
- package/dist/codeIndex/search.js +316 -0
- package/dist/codeIndex/search.js.map +1 -0
- package/dist/codeIndex/shared.d.ts +27 -0
- package/dist/codeIndex/shared.d.ts.map +1 -0
- package/dist/codeIndex/shared.js +46 -0
- package/dist/codeIndex/shared.js.map +1 -0
- package/dist/codeIndex/sqliteCollection.d.ts +81 -0
- package/dist/codeIndex/sqliteCollection.d.ts.map +1 -0
- package/dist/codeIndex/sqliteCollection.js +250 -0
- package/dist/codeIndex/sqliteCollection.js.map +1 -0
- package/dist/codeIndex/whitelist.d.ts +59 -0
- package/dist/codeIndex/whitelist.d.ts.map +1 -0
- package/dist/codeIndex/whitelist.js +188 -0
- package/dist/codeIndex/whitelist.js.map +1 -0
- package/dist/codeIndexDB.d.ts +130 -277
- package/dist/codeIndexDB.d.ts.map +1 -1
- package/dist/codeIndexDB.js +364 -2748
- package/dist/codeIndexDB.js.map +1 -1
- package/dist/codeIndexService.d.ts +87 -12
- package/dist/codeIndexService.d.ts.map +1 -1
- package/dist/codeIndexService.js +110 -34
- package/dist/codeIndexService.js.map +1 -1
- package/dist/componentScanner.d.ts +35 -0
- package/dist/componentScanner.d.ts.map +1 -1
- package/dist/componentScanner.js +114 -80
- package/dist/componentScanner.js.map +1 -1
- package/dist/config/configGeneratePath.d.ts +4 -0
- package/dist/config/configGeneratePath.d.ts.map +1 -1
- package/dist/config/configGeneratePath.js +4 -0
- package/dist/config/configGeneratePath.js.map +1 -1
- package/dist/config/configLoader.d.ts +16 -1
- package/dist/config/configLoader.d.ts.map +1 -1
- package/dist/config/configLoader.js +26 -23
- package/dist/config/configLoader.js.map +1 -1
- package/dist/config/defaults.d.ts +11 -7
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +21 -20
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/effectiveConfig.d.ts +17 -2
- package/dist/config/effectiveConfig.d.ts.map +1 -1
- package/dist/config/effectiveConfig.js +32 -25
- package/dist/config/effectiveConfig.js.map +1 -1
- package/dist/config/lintConfigReader.d.ts +6 -0
- package/dist/config/lintConfigReader.d.ts.map +1 -1
- package/dist/config/lintConfigReader.js +6 -0
- package/dist/config/lintConfigReader.js.map +1 -1
- package/dist/config/staticObjectExtract.d.ts +4 -0
- package/dist/config/staticObjectExtract.d.ts.map +1 -1
- package/dist/config/staticObjectExtract.js +7 -3
- package/dist/config/staticObjectExtract.js.map +1 -1
- package/dist/config/thresholdRationales.d.ts +2 -0
- package/dist/config/thresholdRationales.d.ts.map +1 -1
- package/dist/config/thresholdRationales.js +5 -2
- package/dist/config/thresholdRationales.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +10 -5
- package/dist/constants.js.map +1 -1
- package/dist/conventions/conventionMiner.d.ts +105 -2
- package/dist/conventions/conventionMiner.d.ts.map +1 -1
- package/dist/conventions/conventionMiner.js +334 -259
- package/dist/conventions/conventionMiner.js.map +1 -1
- package/dist/coverage/coverageService.js +4 -4
- package/dist/coverage/coverageService.js.map +1 -1
- package/dist/daemon/args.d.ts +3 -0
- package/dist/daemon/args.d.ts.map +1 -1
- package/dist/daemon/args.js +3 -0
- package/dist/daemon/args.js.map +1 -1
- package/dist/daemon/core.d.ts +33 -27
- package/dist/daemon/core.d.ts.map +1 -1
- package/dist/daemon/core.js +198 -162
- package/dist/daemon/core.js.map +1 -1
- package/dist/daemon/lspServer.d.ts +8 -0
- package/dist/daemon/lspServer.d.ts.map +1 -1
- package/dist/daemon/lspServer.js +8 -0
- package/dist/daemon/lspServer.js.map +1 -1
- package/dist/daemon/main.d.ts +2 -0
- package/dist/daemon/main.d.ts.map +1 -1
- package/dist/daemon/main.js +2 -0
- package/dist/daemon/main.js.map +1 -1
- package/dist/daemon/resolve.d.ts +22 -7
- package/dist/daemon/resolve.d.ts.map +1 -1
- package/dist/daemon/resolve.js +29 -8
- package/dist/daemon/resolve.js.map +1 -1
- package/dist/daemon/socketClient.d.ts +10 -1
- package/dist/daemon/socketClient.d.ts.map +1 -1
- package/dist/daemon/socketClient.js +10 -1
- package/dist/daemon/socketClient.js.map +1 -1
- package/dist/daemon/socketServer.d.ts +13 -0
- package/dist/daemon/socketServer.d.ts.map +1 -1
- package/dist/daemon/socketServer.js +13 -0
- package/dist/daemon/socketServer.js.map +1 -1
- package/dist/dataPaths.d.ts +27 -8
- package/dist/dataPaths.d.ts.map +1 -1
- package/dist/dataPaths.js +28 -44
- package/dist/dataPaths.js.map +1 -1
- package/dist/dismissals.d.ts +22 -1
- package/dist/dismissals.d.ts.map +1 -1
- package/dist/dismissals.js +22 -1
- package/dist/dismissals.js.map +1 -1
- package/dist/enforcement/gate.d.ts +1 -0
- package/dist/enforcement/gate.d.ts.map +1 -1
- package/dist/enforcement/gate.js +1 -0
- package/dist/enforcement/gate.js.map +1 -1
- package/dist/fingerprint.d.ts +6 -0
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +46 -1
- package/dist/fingerprint.js.map +1 -1
- package/dist/functionScanner.d.ts +30 -1
- package/dist/functionScanner.d.ts.map +1 -1
- package/dist/functionScanner.js +258 -256
- package/dist/functionScanner.js.map +1 -1
- package/dist/generators/AWSQConfigGenerator.d.ts +23 -0
- package/dist/generators/AWSQConfigGenerator.d.ts.map +1 -1
- package/dist/generators/AWSQConfigGenerator.js +23 -0
- package/dist/generators/AWSQConfigGenerator.js.map +1 -1
- package/dist/generators/BaseConfigGenerator.d.ts +7 -0
- package/dist/generators/BaseConfigGenerator.d.ts.map +1 -1
- package/dist/generators/BaseConfigGenerator.js +7 -0
- package/dist/generators/BaseConfigGenerator.js.map +1 -1
- package/dist/generators/ClaudeConfigGenerator.d.ts +23 -0
- package/dist/generators/ClaudeConfigGenerator.d.ts.map +1 -1
- package/dist/generators/ClaudeConfigGenerator.js +23 -0
- package/dist/generators/ClaudeConfigGenerator.js.map +1 -1
- package/dist/generators/ClineConfigGenerator.d.ts +23 -0
- package/dist/generators/ClineConfigGenerator.d.ts.map +1 -1
- package/dist/generators/ClineConfigGenerator.js +23 -0
- package/dist/generators/ClineConfigGenerator.js.map +1 -1
- package/dist/generators/CodeiumConfigGenerator.d.ts +23 -0
- package/dist/generators/CodeiumConfigGenerator.d.ts.map +1 -1
- package/dist/generators/CodeiumConfigGenerator.js +23 -0
- package/dist/generators/CodeiumConfigGenerator.js.map +1 -1
- package/dist/generators/CodexConfigGenerator.d.ts +23 -0
- package/dist/generators/CodexConfigGenerator.d.ts.map +1 -1
- package/dist/generators/CodexConfigGenerator.js +23 -0
- package/dist/generators/CodexConfigGenerator.js.map +1 -1
- package/dist/generators/ConfigGeneratorFactory.d.ts +9 -0
- package/dist/generators/ConfigGeneratorFactory.d.ts.map +1 -1
- package/dist/generators/ConfigGeneratorFactory.js +9 -0
- package/dist/generators/ConfigGeneratorFactory.js.map +1 -1
- package/dist/generators/ContinueConfigGenerator.d.ts +23 -0
- package/dist/generators/ContinueConfigGenerator.d.ts.map +1 -1
- package/dist/generators/ContinueConfigGenerator.js +23 -0
- package/dist/generators/ContinueConfigGenerator.js.map +1 -1
- package/dist/generators/CopilotConfigGenerator.d.ts +23 -0
- package/dist/generators/CopilotConfigGenerator.d.ts.map +1 -1
- package/dist/generators/CopilotConfigGenerator.js +23 -0
- package/dist/generators/CopilotConfigGenerator.js.map +1 -1
- package/dist/generators/CursorConfigGenerator.d.ts +23 -0
- package/dist/generators/CursorConfigGenerator.d.ts.map +1 -1
- package/dist/generators/CursorConfigGenerator.js +23 -0
- package/dist/generators/CursorConfigGenerator.js.map +1 -1
- package/dist/generators/GeminiConfigGenerator.d.ts +23 -0
- package/dist/generators/GeminiConfigGenerator.d.ts.map +1 -1
- package/dist/generators/GeminiConfigGenerator.js +23 -0
- package/dist/generators/GeminiConfigGenerator.js.map +1 -1
- package/dist/generators/VSCodeConfigGenerator.d.ts +23 -0
- package/dist/generators/VSCodeConfigGenerator.d.ts.map +1 -1
- package/dist/generators/VSCodeConfigGenerator.js +23 -0
- package/dist/generators/VSCodeConfigGenerator.js.map +1 -1
- package/dist/generators/ZCodeConfigGenerator.d.ts +23 -0
- package/dist/generators/ZCodeConfigGenerator.d.ts.map +1 -1
- package/dist/generators/ZCodeConfigGenerator.js +23 -0
- package/dist/generators/ZCodeConfigGenerator.js.map +1 -1
- package/dist/graph/blastRadius.d.ts.map +1 -1
- package/dist/graph/blastRadius.js +12 -7
- package/dist/graph/blastRadius.js.map +1 -1
- package/dist/graph/callGraph.d.ts +31 -0
- package/dist/graph/callGraph.d.ts.map +1 -1
- package/dist/graph/callGraph.js +62 -32
- package/dist/graph/callGraph.js.map +1 -1
- package/dist/graph/importClassification.d.ts +28 -0
- package/dist/graph/importClassification.d.ts.map +1 -1
- package/dist/graph/importClassification.js +57 -0
- package/dist/graph/importClassification.js.map +1 -1
- package/dist/graph/importGraph.d.ts +38 -0
- package/dist/graph/importGraph.d.ts.map +1 -1
- package/dist/graph/importGraph.js +38 -0
- package/dist/graph/importGraph.js.map +1 -1
- package/dist/graph/outputFormatter.d.ts +12 -4
- package/dist/graph/outputFormatter.d.ts.map +1 -1
- package/dist/graph/outputFormatter.js +12 -62
- package/dist/graph/outputFormatter.js.map +1 -1
- package/dist/hooks/codex.d.ts +8 -1
- package/dist/hooks/codex.d.ts.map +1 -1
- package/dist/hooks/codex.js +7 -0
- package/dist/hooks/codex.js.map +1 -1
- package/dist/hooks/core.d.ts +6 -0
- package/dist/hooks/core.d.ts.map +1 -1
- package/dist/hooks/core.js +6 -1
- package/dist/hooks/core.js.map +1 -1
- package/dist/hooks/cursor.d.ts +11 -1
- package/dist/hooks/cursor.d.ts.map +1 -1
- package/dist/hooks/cursor.js +10 -0
- package/dist/hooks/cursor.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/installConfig.d.ts +23 -5
- package/dist/installConfig.d.ts.map +1 -1
- package/dist/installConfig.js +23 -5
- package/dist/installConfig.js.map +1 -1
- package/dist/installer.d.ts +6 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +6 -0
- package/dist/installer.js.map +1 -1
- package/dist/invariants/ruleEngine.d.ts +3 -0
- package/dist/invariants/ruleEngine.d.ts.map +1 -1
- package/dist/invariants/ruleEngine.js +156 -119
- package/dist/invariants/ruleEngine.js.map +1 -1
- package/dist/invariants/ruleValidator.d.ts +3 -0
- package/dist/invariants/ruleValidator.d.ts.map +1 -1
- package/dist/invariants/ruleValidator.js +185 -178
- package/dist/invariants/ruleValidator.js.map +1 -1
- package/dist/languages/LanguageOrchestrator.d.ts +4 -1
- package/dist/languages/LanguageOrchestrator.d.ts.map +1 -1
- package/dist/languages/LanguageOrchestrator.js +8 -19
- package/dist/languages/LanguageOrchestrator.js.map +1 -1
- package/dist/languages/RuntimeManager.d.ts +8 -0
- package/dist/languages/RuntimeManager.d.ts.map +1 -1
- package/dist/languages/RuntimeManager.js +55 -5
- package/dist/languages/RuntimeManager.js.map +1 -1
- package/dist/languages/UniversalAnalyzer.js +1 -1
- package/dist/languages/UniversalAnalyzer.js.map +1 -1
- package/dist/languages/adapterBridge.d.ts +4 -0
- package/dist/languages/adapterBridge.d.ts.map +1 -1
- package/dist/languages/adapterBridge.js +37 -3
- package/dist/languages/adapterBridge.js.map +1 -1
- package/dist/languages/go/GoAdapter.d.ts.map +1 -1
- package/dist/languages/go/GoAdapter.js +11 -14
- package/dist/languages/go/GoAdapter.js.map +1 -1
- package/dist/languages/go/analyzer-darwin-amd64 +0 -0
- package/dist/languages/go/analyzer-darwin-arm64 +0 -0
- package/dist/languages/go/analyzer-linux-amd64 +0 -0
- package/dist/languages/go/analyzer-linux-arm64 +0 -0
- package/dist/languages/go/analyzer-src/analyzer.go +2 -0
- package/dist/languages/go/analyzer-src/dataaccess.go +388 -0
- package/dist/languages/go/analyzer-src/types.go +8 -0
- package/dist/languages/go/analyzer-windows-amd64.exe +0 -0
- package/dist/languages/go/database-packages.json +8 -0
- package/dist/languages/go/goResolution.d.ts +229 -0
- package/dist/languages/go/goResolution.d.ts.map +1 -0
- package/dist/languages/go/goResolution.js +799 -0
- package/dist/languages/go/goResolution.js.map +1 -0
- package/dist/languages/go/stdlib-packages.json +353 -0
- package/dist/languages/go/tenantInputs.d.ts +37 -0
- package/dist/languages/go/tenantInputs.d.ts.map +1 -0
- package/dist/languages/go/tenantInputs.js +121 -0
- package/dist/languages/go/tenantInputs.js.map +1 -0
- package/dist/languages/index.d.ts +1 -0
- package/dist/languages/index.d.ts.map +1 -1
- package/dist/languages/index.js +5 -0
- package/dist/languages/index.js.map +1 -1
- package/dist/languages/json/JsonAdapter.d.ts +177 -0
- package/dist/languages/json/JsonAdapter.d.ts.map +1 -0
- package/dist/languages/json/JsonAdapter.js +531 -0
- package/dist/languages/json/JsonAdapter.js.map +1 -0
- package/dist/languages/locationIndex.d.ts +41 -0
- package/dist/languages/locationIndex.d.ts.map +1 -0
- package/dist/languages/locationIndex.js +42 -0
- package/dist/languages/locationIndex.js.map +1 -0
- package/dist/languages/sql/dialectDetection.d.ts +57 -0
- package/dist/languages/sql/dialectDetection.d.ts.map +1 -0
- package/dist/languages/sql/dialectDetection.js +135 -0
- package/dist/languages/sql/dialectDetection.js.map +1 -0
- package/dist/languages/sql/sqlAst.d.ts +494 -0
- package/dist/languages/sql/sqlAst.d.ts.map +1 -0
- package/dist/languages/sql/sqlAst.js +1817 -0
- package/dist/languages/sql/sqlAst.js.map +1 -0
- package/dist/languages/testConventions.d.ts +12 -1
- package/dist/languages/testConventions.d.ts.map +1 -1
- package/dist/languages/testConventions.js +13 -1
- package/dist/languages/testConventions.js.map +1 -1
- package/dist/languages/tree-sitter/TreeSitterCssAdapter.js +1 -1
- package/dist/languages/tree-sitter/TreeSitterCssAdapter.js.map +1 -1
- package/dist/languages/tree-sitter/converter.js +2 -2
- package/dist/languages/tree-sitter/converter.js.map +1 -1
- package/dist/languages/tree-sitter/parser.d.ts +3 -4
- package/dist/languages/tree-sitter/parser.d.ts.map +1 -1
- package/dist/languages/tree-sitter/parser.js +10 -4
- package/dist/languages/tree-sitter/parser.js.map +1 -1
- package/dist/languages/tree-sitter/rawNode.d.ts +3 -0
- package/dist/languages/tree-sitter/rawNode.d.ts.map +1 -1
- package/dist/languages/tree-sitter/rawNode.js +3 -0
- package/dist/languages/tree-sitter/rawNode.js.map +1 -1
- package/dist/languages/types.d.ts +7 -0
- package/dist/languages/types.d.ts.map +1 -1
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.d.ts +36 -0
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.d.ts.map +1 -1
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js +168 -45
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js.map +1 -1
- package/dist/languages/typescript/database-packages.json +19 -0
- package/dist/ledger.d.ts +118 -2
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +167 -45
- package/dist/ledger.js.map +1 -1
- package/dist/legacyIndexNotice.d.ts +32 -0
- package/dist/legacyIndexNotice.d.ts.map +1 -0
- package/dist/legacyIndexNotice.js +89 -0
- package/dist/legacyIndexNotice.js.map +1 -0
- package/dist/mcp-tools/discoveryQueries.d.ts +55 -0
- package/dist/mcp-tools/discoveryQueries.d.ts.map +1 -0
- package/dist/mcp-tools/discoveryQueries.js +157 -0
- package/dist/mcp-tools/discoveryQueries.js.map +1 -0
- package/dist/mcp-tools/projectTasks.d.ts +9 -123
- package/dist/mcp-tools/projectTasks.d.ts.map +1 -1
- package/dist/mcp-tools/projectTasks.js +180 -170
- package/dist/mcp-tools/projectTasks.js.map +1 -1
- package/dist/mcp-tools/whitelistTools.d.ts +20 -0
- package/dist/mcp-tools/whitelistTools.d.ts.map +1 -1
- package/dist/mcp-tools/whitelistTools.js +20 -0
- package/dist/mcp-tools/whitelistTools.js.map +1 -1
- package/dist/mcp-tools/workflowGuide.d.ts +9 -0
- package/dist/mcp-tools/workflowGuide.d.ts.map +1 -1
- package/dist/mcp-tools/workflowGuide.js +13 -5
- package/dist/mcp-tools/workflowGuide.js.map +1 -1
- package/dist/mcp-tools-shared.d.ts +78 -0
- package/dist/mcp-tools-shared.d.ts.map +1 -1
- package/dist/mcp-tools-shared.js +203 -340
- package/dist/mcp-tools-shared.js.map +1 -1
- package/dist/mcp-ui-simple.d.ts +2 -0
- package/dist/mcp-ui-simple.d.ts.map +1 -1
- package/dist/mcp-ui-simple.js +12 -5
- package/dist/mcp-ui-simple.js.map +1 -1
- package/dist/mcp.d.ts +6 -0
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +832 -851
- package/dist/mcp.js.map +1 -1
- package/dist/mcpAuditJobs.d.ts +29 -33
- package/dist/mcpAuditJobs.d.ts.map +1 -1
- package/dist/mcpAuditJobs.js +102 -791
- package/dist/mcpAuditJobs.js.map +1 -1
- package/dist/mcpAutoIndex.d.ts +5 -0
- package/dist/mcpAutoIndex.d.ts.map +1 -1
- package/dist/mcpAutoIndex.js +7 -2
- package/dist/mcpAutoIndex.js.map +1 -1
- package/dist/mcpDiagnostics.d.ts +7 -0
- package/dist/mcpDiagnostics.d.ts.map +1 -1
- package/dist/mcpDiagnostics.js +34 -9
- package/dist/mcpDiagnostics.js.map +1 -1
- package/dist/mcpToolErrors.d.ts +16 -0
- package/dist/mcpToolErrors.d.ts.map +1 -1
- package/dist/mcpToolErrors.js +16 -0
- package/dist/mcpToolErrors.js.map +1 -1
- package/dist/nextFile.d.ts +6 -0
- package/dist/nextFile.d.ts.map +1 -1
- package/dist/nextFile.js +6 -0
- package/dist/nextFile.js.map +1 -1
- package/dist/nextFileIncremental.d.ts +44 -4
- package/dist/nextFileIncremental.d.ts.map +1 -1
- package/dist/nextFileIncremental.js +47 -7
- package/dist/nextFileIncremental.js.map +1 -1
- package/dist/phase/batchFunctions.d.ts +38 -0
- package/dist/phase/batchFunctions.d.ts.map +1 -0
- package/dist/phase/batchFunctions.js +64 -0
- package/dist/phase/batchFunctions.js.map +1 -0
- package/dist/phase/checks.d.ts +39 -0
- package/dist/phase/checks.d.ts.map +1 -0
- package/dist/phase/checks.js +48 -0
- package/dist/phase/checks.js.map +1 -0
- package/dist/phase/codeBlocks.d.ts +25 -0
- package/dist/phase/codeBlocks.d.ts.map +1 -0
- package/dist/phase/codeBlocks.js +268 -0
- package/dist/phase/codeBlocks.js.map +1 -0
- package/dist/phase/colorMath.d.ts +41 -0
- package/dist/phase/colorMath.d.ts.map +1 -0
- package/dist/phase/colorMath.js +109 -0
- package/dist/phase/colorMath.js.map +1 -0
- package/dist/phase/config.d.ts +29 -0
- package/dist/phase/config.d.ts.map +1 -0
- package/dist/phase/config.js +54 -0
- package/dist/phase/config.js.map +1 -0
- package/dist/phase/consumed.d.ts +47 -0
- package/dist/phase/consumed.d.ts.map +1 -0
- package/dist/phase/consumed.js +22 -0
- package/dist/phase/consumed.js.map +1 -0
- package/dist/phase/conventionMining.d.ts +59 -0
- package/dist/phase/conventionMining.d.ts.map +1 -0
- package/dist/phase/conventionMining.js +152 -0
- package/dist/phase/conventionMining.js.map +1 -0
- package/dist/phase/coverage.d.ts +65 -0
- package/dist/phase/coverage.d.ts.map +1 -0
- package/dist/phase/coverage.js +121 -0
- package/dist/phase/coverage.js.map +1 -0
- package/dist/phase/dag.d.ts +49 -0
- package/dist/phase/dag.d.ts.map +1 -0
- package/dist/phase/dag.js +120 -0
- package/dist/phase/dag.js.map +1 -0
- package/dist/phase/dataAccessCalls.d.ts +33 -0
- package/dist/phase/dataAccessCalls.d.ts.map +1 -0
- package/dist/phase/dataAccessCalls.js +42 -0
- package/dist/phase/dataAccessCalls.js.map +1 -0
- package/dist/phase/dataAccessCallsCandidates.d.ts +25 -0
- package/dist/phase/dataAccessCallsCandidates.d.ts.map +1 -0
- package/dist/phase/dataAccessCallsCandidates.js +27 -0
- package/dist/phase/dataAccessCallsCandidates.js.map +1 -0
- package/dist/phase/dynamicSql.d.ts +18 -0
- package/dist/phase/dynamicSql.d.ts.map +1 -0
- package/dist/phase/dynamicSql.js +20 -0
- package/dist/phase/dynamicSql.js.map +1 -0
- package/dist/phase/exportForm.d.ts +23 -0
- package/dist/phase/exportForm.d.ts.map +1 -0
- package/dist/phase/exportForm.js +29 -0
- package/dist/phase/exportForm.js.map +1 -0
- package/dist/phase/exportSymbols.d.ts +21 -0
- package/dist/phase/exportSymbols.d.ts.map +1 -0
- package/dist/phase/exportSymbols.js +28 -0
- package/dist/phase/exportSymbols.js.map +1 -0
- package/dist/phase/fileHeader.d.ts +15 -0
- package/dist/phase/fileHeader.d.ts.map +1 -0
- package/dist/phase/fileHeader.js +33 -0
- package/dist/phase/fileHeader.js.map +1 -0
- package/dist/phase/fileImports.d.ts +39 -0
- package/dist/phase/fileImports.d.ts.map +1 -0
- package/dist/phase/fileImports.js +138 -0
- package/dist/phase/fileImports.js.map +1 -0
- package/dist/phase/fileSymbols.d.ts +25 -0
- package/dist/phase/fileSymbols.d.ts.map +1 -0
- package/dist/phase/fileSymbols.js +302 -0
- package/dist/phase/fileSymbols.js.map +1 -0
- package/dist/phase/functionBodies.d.ts +28 -0
- package/dist/phase/functionBodies.d.ts.map +1 -0
- package/dist/phase/functionBodies.js +67 -0
- package/dist/phase/functionBodies.js.map +1 -0
- package/dist/phase/functionIndex.d.ts +28 -0
- package/dist/phase/functionIndex.d.ts.map +1 -0
- package/dist/phase/functionIndex.js +152 -0
- package/dist/phase/functionIndex.js.map +1 -0
- package/dist/phase/goFunctionAnalysis.d.ts +47 -0
- package/dist/phase/goFunctionAnalysis.d.ts.map +1 -0
- package/dist/phase/goFunctionAnalysis.js +291 -0
- package/dist/phase/goFunctionAnalysis.js.map +1 -0
- package/dist/phase/goFunctions.d.ts +38 -0
- package/dist/phase/goFunctions.d.ts.map +1 -0
- package/dist/phase/goFunctions.js +154 -0
- package/dist/phase/goFunctions.js.map +1 -0
- package/dist/phase/goImports.d.ts +29 -0
- package/dist/phase/goImports.d.ts.map +1 -0
- package/dist/phase/goImports.js +68 -0
- package/dist/phase/goImports.js.map +1 -0
- package/dist/phase/goPackageBindings.d.ts +22 -0
- package/dist/phase/goPackageBindings.d.ts.map +1 -0
- package/dist/phase/goPackageBindings.js +30 -0
- package/dist/phase/goPackageBindings.js.map +1 -0
- package/dist/phase/goSwitches.d.ts +28 -0
- package/dist/phase/goSwitches.d.ts.map +1 -0
- package/dist/phase/goSwitches.js +52 -0
- package/dist/phase/goSwitches.js.map +1 -0
- package/dist/phase/importForm.d.ts +20 -0
- package/dist/phase/importForm.d.ts.map +1 -0
- package/dist/phase/importForm.js +27 -0
- package/dist/phase/importForm.js.map +1 -0
- package/dist/phase/importSpecifiers.d.ts +20 -0
- package/dist/phase/importSpecifiers.d.ts.map +1 -0
- package/dist/phase/importSpecifiers.js +30 -0
- package/dist/phase/importSpecifiers.js.map +1 -0
- package/dist/phase/imports.d.ts +18 -0
- package/dist/phase/imports.d.ts.map +1 -0
- package/dist/phase/imports.js +25 -0
- package/dist/phase/imports.js.map +1 -0
- package/dist/phase/jsonDocument.d.ts +26 -0
- package/dist/phase/jsonDocument.d.ts.map +1 -0
- package/dist/phase/jsonDocument.js +36 -0
- package/dist/phase/jsonDocument.js.map +1 -0
- package/dist/phase/localBinding.d.ts +33 -0
- package/dist/phase/localBinding.d.ts.map +1 -0
- package/dist/phase/localBinding.js +208 -0
- package/dist/phase/localBinding.js.map +1 -0
- package/dist/phase/loopQueries.d.ts +31 -0
- package/dist/phase/loopQueries.d.ts.map +1 -0
- package/dist/phase/loopQueries.js +44 -0
- package/dist/phase/loopQueries.js.map +1 -0
- package/dist/phase/loopQueryCandidates.d.ts +26 -0
- package/dist/phase/loopQueryCandidates.d.ts.map +1 -0
- package/dist/phase/loopQueryCandidates.js +28 -0
- package/dist/phase/loopQueryCandidates.js.map +1 -0
- package/dist/phase/oracles.d.ts +216 -0
- package/dist/phase/oracles.d.ts.map +1 -0
- package/dist/phase/oracles.js +484 -0
- package/dist/phase/oracles.js.map +1 -0
- package/dist/phase/phaseModel.d.ts +190 -0
- package/dist/phase/phaseModel.d.ts.map +1 -0
- package/dist/phase/phaseModel.js +468 -0
- package/dist/phase/phaseModel.js.map +1 -0
- package/dist/phase/producers.d.ts +450 -0
- package/dist/phase/producers.d.ts.map +1 -0
- package/dist/phase/producers.js +1027 -0
- package/dist/phase/producers.js.map +1 -0
- package/dist/phase/querySiteCandidates.d.ts +27 -0
- package/dist/phase/querySiteCandidates.d.ts.map +1 -0
- package/dist/phase/querySiteCandidates.js +66 -0
- package/dist/phase/querySiteCandidates.js.map +1 -0
- package/dist/phase/querySites.d.ts +30 -0
- package/dist/phase/querySites.d.ts.map +1 -0
- package/dist/phase/querySites.js +93 -0
- package/dist/phase/querySites.js.map +1 -0
- package/dist/phase/reachability.d.ts +61 -0
- package/dist/phase/reachability.d.ts.map +1 -0
- package/dist/phase/reachability.js +104 -0
- package/dist/phase/reachability.js.map +1 -0
- package/dist/phase/reactComponents.d.ts +33 -0
- package/dist/phase/reactComponents.d.ts.map +1 -0
- package/dist/phase/reactComponents.js +47 -0
- package/dist/phase/reactComponents.js.map +1 -0
- package/dist/phase/receiverActivity.d.ts +35 -0
- package/dist/phase/receiverActivity.d.ts.map +1 -0
- package/dist/phase/receiverActivity.js +66 -0
- package/dist/phase/receiverActivity.js.map +1 -0
- package/dist/phase/receiverConsumers.d.ts +200 -0
- package/dist/phase/receiverConsumers.d.ts.map +1 -0
- package/dist/phase/receiverConsumers.js +1025 -0
- package/dist/phase/receiverConsumers.js.map +1 -0
- package/dist/phase/receiverProvenance.d.ts +97 -0
- package/dist/phase/receiverProvenance.d.ts.map +1 -0
- package/dist/phase/receiverProvenance.js +337 -0
- package/dist/phase/receiverProvenance.js.map +1 -0
- package/dist/phase/routing.d.ts +47 -0
- package/dist/phase/routing.d.ts.map +1 -0
- package/dist/phase/routing.js +62 -0
- package/dist/phase/routing.js.map +1 -0
- package/dist/phase/rules/conventions.d.ts +61 -0
- package/dist/phase/rules/conventions.d.ts.map +1 -0
- package/dist/phase/rules/conventions.js +403 -0
- package/dist/phase/rules/conventions.js.map +1 -0
- package/dist/phase/rules/crossDomain.d.ts +102 -0
- package/dist/phase/rules/crossDomain.d.ts.map +1 -0
- package/dist/phase/rules/crossDomain.js +918 -0
- package/dist/phase/rules/crossDomain.js.map +1 -0
- package/dist/phase/rules/dataAccess.d.ts +62 -0
- package/dist/phase/rules/dataAccess.d.ts.map +1 -0
- package/dist/phase/rules/dataAccess.js +480 -0
- package/dist/phase/rules/dataAccess.js.map +1 -0
- package/dist/phase/rules/dependencyGraph.d.ts +44 -0
- package/dist/phase/rules/dependencyGraph.d.ts.map +1 -0
- package/dist/phase/rules/dependencyGraph.js +260 -0
- package/dist/phase/rules/dependencyGraph.js.map +1 -0
- package/dist/phase/rules/documentation.d.ts +45 -0
- package/dist/phase/rules/documentation.d.ts.map +1 -0
- package/dist/phase/rules/documentation.js +340 -0
- package/dist/phase/rules/documentation.js.map +1 -0
- package/dist/phase/rules/dry.d.ts +109 -0
- package/dist/phase/rules/dry.d.ts.map +1 -0
- package/dist/phase/rules/dry.js +803 -0
- package/dist/phase/rules/dry.js.map +1 -0
- package/dist/phase/rules/fileDocumentation.d.ts +36 -0
- package/dist/phase/rules/fileDocumentation.d.ts.map +1 -0
- package/dist/phase/rules/fileDocumentation.js +134 -0
- package/dist/phase/rules/fileDocumentation.js.map +1 -0
- package/dist/phase/rules/functionBodies.d.ts +33 -0
- package/dist/phase/rules/functionBodies.d.ts.map +1 -0
- package/dist/phase/rules/functionBodies.js +71 -0
- package/dist/phase/rules/functionBodies.js.map +1 -0
- package/dist/phase/rules/goRules.d.ts +49 -0
- package/dist/phase/rules/goRules.d.ts.map +1 -0
- package/dist/phase/rules/goRules.js +209 -0
- package/dist/phase/rules/goRules.js.map +1 -0
- package/dist/phase/rules/querySites.d.ts +29 -0
- package/dist/phase/rules/querySites.d.ts.map +1 -0
- package/dist/phase/rules/querySites.js +94 -0
- package/dist/phase/rules/querySites.js.map +1 -0
- package/dist/phase/rules/react.d.ts +38 -0
- package/dist/phase/rules/react.d.ts.map +1 -0
- package/dist/phase/rules/react.js +202 -0
- package/dist/phase/rules/react.js.map +1 -0
- package/dist/phase/rules/registry.d.ts +170 -0
- package/dist/phase/rules/registry.d.ts.map +1 -0
- package/dist/phase/rules/registry.js +103 -0
- package/dist/phase/rules/registry.js.map +1 -0
- package/dist/phase/rules/schema.d.ts +79 -0
- package/dist/phase/rules/schema.d.ts.map +1 -0
- package/dist/phase/rules/schema.js +273 -0
- package/dist/phase/rules/schema.js.map +1 -0
- package/dist/phase/rules/schemaJson.d.ts +32 -0
- package/dist/phase/rules/schemaJson.d.ts.map +1 -0
- package/dist/phase/rules/schemaJson.js +81 -0
- package/dist/phase/rules/schemaJson.js.map +1 -0
- package/dist/phase/rules/schemaValidator.d.ts +38 -0
- package/dist/phase/rules/schemaValidator.d.ts.map +1 -0
- package/dist/phase/rules/schemaValidator.js +107 -0
- package/dist/phase/rules/schemaValidator.js.map +1 -0
- package/dist/phase/rules/secrets.d.ts +34 -0
- package/dist/phase/rules/secrets.d.ts.map +1 -0
- package/dist/phase/rules/secrets.js +208 -0
- package/dist/phase/rules/secrets.js.map +1 -0
- package/dist/phase/rules/security.d.ts +30 -0
- package/dist/phase/rules/security.d.ts.map +1 -0
- package/dist/phase/rules/security.js +85 -0
- package/dist/phase/rules/security.js.map +1 -0
- package/dist/phase/rules/securityDefects.d.ts +37 -0
- package/dist/phase/rules/securityDefects.d.ts.map +1 -0
- package/dist/phase/rules/securityDefects.js +167 -0
- package/dist/phase/rules/securityDefects.js.map +1 -0
- package/dist/phase/rules/solid.d.ts +61 -0
- package/dist/phase/rules/solid.d.ts.map +1 -0
- package/dist/phase/rules/solid.js +562 -0
- package/dist/phase/rules/solid.js.map +1 -0
- package/dist/phase/rules/styles.d.ts +77 -0
- package/dist/phase/rules/styles.d.ts.map +1 -0
- package/dist/phase/rules/styles.js +868 -0
- package/dist/phase/rules/styles.js.map +1 -0
- package/dist/phase/rules/unreferencedModule.d.ts +26 -0
- package/dist/phase/rules/unreferencedModule.d.ts.map +1 -0
- package/dist/phase/rules/unreferencedModule.js +61 -0
- package/dist/phase/rules/unreferencedModule.js.map +1 -0
- package/dist/phase/runner.d.ts +549 -0
- package/dist/phase/runner.d.ts.map +1 -0
- package/dist/phase/runner.js +1098 -0
- package/dist/phase/runner.js.map +1 -0
- package/dist/phase/schemaCode.d.ts +34 -0
- package/dist/phase/schemaCode.d.ts.map +1 -0
- package/dist/phase/schemaCode.js +53 -0
- package/dist/phase/schemaCode.js.map +1 -0
- package/dist/phase/schemaObjects.d.ts +37 -0
- package/dist/phase/schemaObjects.d.ts.map +1 -0
- package/dist/phase/schemaObjects.js +139 -0
- package/dist/phase/schemaObjects.js.map +1 -0
- package/dist/phase/schemaUsage.d.ts +30 -0
- package/dist/phase/schemaUsage.d.ts.map +1 -0
- package/dist/phase/schemaUsage.js +99 -0
- package/dist/phase/schemaUsage.js.map +1 -0
- package/dist/phase/schemaUsageCandidates.d.ts +32 -0
- package/dist/phase/schemaUsageCandidates.d.ts.map +1 -0
- package/dist/phase/schemaUsageCandidates.js +165 -0
- package/dist/phase/schemaUsageCandidates.js.map +1 -0
- package/dist/phase/schemaValidations.d.ts +34 -0
- package/dist/phase/schemaValidations.d.ts.map +1 -0
- package/dist/phase/schemaValidations.js +53 -0
- package/dist/phase/schemaValidations.js.map +1 -0
- package/dist/phase/secretCandidates.d.ts +28 -0
- package/dist/phase/secretCandidates.d.ts.map +1 -0
- package/dist/phase/secretCandidates.js +132 -0
- package/dist/phase/secretCandidates.js.map +1 -0
- package/dist/phase/securityCandidates.d.ts +29 -0
- package/dist/phase/securityCandidates.d.ts.map +1 -0
- package/dist/phase/securityCandidates.js +469 -0
- package/dist/phase/securityCandidates.js.map +1 -0
- package/dist/phase/seeded-defects.d.ts +18 -0
- package/dist/phase/seeded-defects.d.ts.map +1 -0
- package/dist/phase/seeded-defects.js +61 -0
- package/dist/phase/seeded-defects.js.map +1 -0
- package/dist/phase/stringLiterals.d.ts +24 -0
- package/dist/phase/stringLiterals.d.ts.map +1 -0
- package/dist/phase/stringLiterals.js +35 -0
- package/dist/phase/stringLiterals.js.map +1 -0
- package/dist/phase/stylesCss.d.ts +25 -0
- package/dist/phase/stylesCss.d.ts.map +1 -0
- package/dist/phase/stylesCss.js +34 -0
- package/dist/phase/stylesCss.js.map +1 -0
- package/dist/phase/stylesMarkup.d.ts +31 -0
- package/dist/phase/stylesMarkup.d.ts.map +1 -0
- package/dist/phase/stylesMarkup.js +48 -0
- package/dist/phase/stylesMarkup.js.map +1 -0
- package/dist/phase/stylesSource.d.ts +36 -0
- package/dist/phase/stylesSource.d.ts.map +1 -0
- package/dist/phase/stylesSource.js +50 -0
- package/dist/phase/stylesSource.js.map +1 -0
- package/dist/phase/typeDeclarations.d.ts +33 -0
- package/dist/phase/typeDeclarations.d.ts.map +1 -0
- package/dist/phase/typeDeclarations.js +76 -0
- package/dist/phase/typeDeclarations.js.map +1 -0
- package/dist/phase/types.d.ts +2191 -0
- package/dist/phase/types.d.ts.map +1 -0
- package/dist/phase/types.js +27 -0
- package/dist/phase/types.js.map +1 -0
- package/dist/phase/withinFileProvenance.d.ts +50 -0
- package/dist/phase/withinFileProvenance.d.ts.map +1 -0
- package/dist/phase/withinFileProvenance.js +112 -0
- package/dist/phase/withinFileProvenance.js.map +1 -0
- package/dist/pipeline.d.ts +37 -30
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +131 -326
- package/dist/pipeline.js.map +1 -1
- package/dist/pipelineAdapters.d.ts +104 -21
- package/dist/pipelineAdapters.d.ts.map +1 -1
- package/dist/pipelineAdapters.js +1145 -988
- package/dist/pipelineAdapters.js.map +1 -1
- package/dist/pipelineTypes.d.ts +21 -0
- package/dist/pipelineTypes.d.ts.map +1 -1
- package/dist/pipelineTypes.js +21 -10
- package/dist/pipelineTypes.js.map +1 -1
- package/dist/presets/presets.d.ts +9 -2
- package/dist/presets/presets.d.ts.map +1 -1
- package/dist/presets/presets.js +15 -26
- package/dist/presets/presets.js.map +1 -1
- package/dist/reporting/csvReportGenerator.d.ts +14 -3
- package/dist/reporting/csvReportGenerator.d.ts.map +1 -1
- package/dist/reporting/csvReportGenerator.js +14 -3
- package/dist/reporting/csvReportGenerator.js.map +1 -1
- package/dist/reporting/htmlReportGenerator.d.ts +5 -1
- package/dist/reporting/htmlReportGenerator.d.ts.map +1 -1
- package/dist/reporting/htmlReportGenerator.js +5 -1
- package/dist/reporting/htmlReportGenerator.js.map +1 -1
- package/dist/reporting/jsonReportGenerator.d.ts +9 -2
- package/dist/reporting/jsonReportGenerator.d.ts.map +1 -1
- package/dist/reporting/jsonReportGenerator.js +19 -5
- package/dist/reporting/jsonReportGenerator.js.map +1 -1
- package/dist/reporting/reportGenerator.d.ts +9 -2
- package/dist/reporting/reportGenerator.d.ts.map +1 -1
- package/dist/reporting/reportGenerator.js +9 -2
- package/dist/reporting/reportGenerator.js.map +1 -1
- package/dist/reporting/sarifReportGenerator.d.ts +14 -0
- package/dist/reporting/sarifReportGenerator.d.ts.map +1 -1
- package/dist/reporting/sarifReportGenerator.js +14 -0
- package/dist/reporting/sarifReportGenerator.js.map +1 -1
- package/dist/reporting/sizeDistribution.d.ts +19 -2
- package/dist/reporting/sizeDistribution.d.ts.map +1 -1
- package/dist/reporting/sizeDistribution.js +23 -5
- package/dist/reporting/sizeDistribution.js.map +1 -1
- package/dist/ruleAliases.d.ts +6 -8
- package/dist/ruleAliases.d.ts.map +1 -1
- package/dist/ruleAliases.js +29 -4
- package/dist/ruleAliases.js.map +1 -1
- package/dist/search/QueryParser.d.ts +1 -0
- package/dist/search/QueryParser.d.ts.map +1 -1
- package/dist/search/QueryParser.js +32 -91
- package/dist/search/QueryParser.js.map +1 -1
- package/dist/services/CodeMapGenerator.d.ts +19 -20
- package/dist/services/CodeMapGenerator.d.ts.map +1 -1
- package/dist/services/CodeMapGenerator.js +214 -194
- package/dist/services/CodeMapGenerator.js.map +1 -1
- package/dist/services/ProjectTaskRepository.d.ts +65 -3
- package/dist/services/ProjectTaskRepository.d.ts.map +1 -1
- package/dist/services/ProjectTaskRepository.js +94 -25
- package/dist/services/ProjectTaskRepository.js.map +1 -1
- package/dist/services/auditJobService.d.ts +17 -1
- package/dist/services/auditJobService.d.ts.map +1 -1
- package/dist/services/auditJobService.js +16 -0
- package/dist/services/auditJobService.js.map +1 -1
- package/dist/services/fileAccounting.d.ts +43 -5
- package/dist/services/fileAccounting.d.ts.map +1 -1
- package/dist/services/fileAccounting.js +48 -9
- package/dist/services/fileAccounting.js.map +1 -1
- package/dist/services/projectTaskHelpers.d.ts +45 -0
- package/dist/services/projectTaskHelpers.d.ts.map +1 -1
- package/dist/services/projectTaskHelpers.js +45 -0
- package/dist/services/projectTaskHelpers.js.map +1 -1
- package/dist/services/whitelistService.d.ts +40 -5
- package/dist/services/whitelistService.d.ts.map +1 -1
- package/dist/services/whitelistService.js +87 -46
- package/dist/services/whitelistService.js.map +1 -1
- package/dist/sqlite/betterSqlite3.d.ts +35 -1
- package/dist/sqlite/betterSqlite3.d.ts.map +1 -1
- package/dist/sqlite/betterSqlite3.js +35 -1
- package/dist/sqlite/betterSqlite3.js.map +1 -1
- package/dist/sqlite/driver.d.ts +23 -0
- package/dist/sqlite/driver.d.ts.map +1 -1
- package/dist/sqlite/driver.js +23 -0
- package/dist/sqlite/driver.js.map +1 -1
- package/dist/sqlite/nodeSqlite.d.ts +35 -1
- package/dist/sqlite/nodeSqlite.d.ts.map +1 -1
- package/dist/sqlite/nodeSqlite.js +35 -1
- package/dist/sqlite/nodeSqlite.js.map +1 -1
- package/dist/structuralSignature.d.ts +9 -0
- package/dist/structuralSignature.d.ts.map +1 -1
- package/dist/structuralSignature.js +9 -0
- package/dist/structuralSignature.js.map +1 -1
- package/dist/styles/cssAstExtractor.d.ts +15 -0
- package/dist/styles/cssAstExtractor.d.ts.map +1 -1
- package/dist/styles/cssAstExtractor.js +15 -0
- package/dist/styles/cssAstExtractor.js.map +1 -1
- package/dist/styles/normalizer.d.ts +6 -0
- package/dist/styles/normalizer.d.ts.map +1 -1
- package/dist/styles/normalizer.js +6 -0
- package/dist/styles/normalizer.js.map +1 -1
- package/dist/styles/styleExtractor.d.ts +29 -2
- package/dist/styles/styleExtractor.d.ts.map +1 -1
- package/dist/styles/styleExtractor.js +67 -48
- package/dist/styles/styleExtractor.js.map +1 -1
- package/dist/styles/styleIndexer.d.ts +8 -0
- package/dist/styles/styleIndexer.d.ts.map +1 -1
- package/dist/styles/styleIndexer.js +135 -138
- package/dist/styles/styleIndexer.js.map +1 -1
- package/dist/styles/tailwindConfigLoader.d.ts +12 -0
- package/dist/styles/tailwindConfigLoader.d.ts.map +1 -1
- package/dist/styles/tailwindConfigLoader.js +12 -0
- package/dist/styles/tailwindConfigLoader.js.map +1 -1
- package/dist/styles/tailwindExpander.d.ts +3 -0
- package/dist/styles/tailwindExpander.d.ts.map +1 -1
- package/dist/styles/tailwindExpander.js +8 -4
- package/dist/styles/tailwindExpander.js.map +1 -1
- package/dist/styles/tailwindProbe.d.ts +9 -0
- package/dist/styles/tailwindProbe.d.ts.map +1 -1
- package/dist/styles/tailwindProbe.js +181 -166
- package/dist/styles/tailwindProbe.js.map +1 -1
- package/dist/styles/tailwindUtilityExpander.d.ts +13 -0
- package/dist/styles/tailwindUtilityExpander.d.ts.map +1 -1
- package/dist/styles/tailwindUtilityExpander.js +13 -0
- package/dist/styles/tailwindUtilityExpander.js.map +1 -1
- package/dist/symbols.d.ts +13 -11
- package/dist/symbols.d.ts.map +1 -1
- package/dist/symbols.js +14 -21
- package/dist/symbols.js.map +1 -1
- package/dist/telemetry.d.ts +31 -3
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +31 -3
- package/dist/telemetry.js.map +1 -1
- package/dist/tool-registry.d.ts +37 -1
- package/dist/tool-registry.d.ts.map +1 -1
- package/dist/tool-registry.js +37 -1
- package/dist/tool-registry.js.map +1 -1
- package/dist/types.d.ts +106 -92
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -16
- package/dist/types.js.map +1 -1
- package/dist/ui/InteractivePrompts.d.ts +12 -0
- package/dist/ui/InteractivePrompts.d.ts.map +1 -1
- package/dist/ui/InteractivePrompts.js +12 -0
- package/dist/ui/InteractivePrompts.js.map +1 -1
- package/dist/utils/astParser.d.ts +15 -0
- package/dist/utils/astParser.d.ts.map +1 -1
- package/dist/utils/astParser.js +15 -0
- package/dist/utils/astParser.js.map +1 -1
- package/dist/utils/astUtils.d.ts +60 -0
- package/dist/utils/astUtils.d.ts.map +1 -1
- package/dist/utils/astUtils.js +350 -362
- package/dist/utils/astUtils.js.map +1 -1
- package/dist/utils/contentHash.d.ts +22 -0
- package/dist/utils/contentHash.d.ts.map +1 -0
- package/dist/utils/contentHash.js +26 -0
- package/dist/utils/contentHash.js.map +1 -0
- package/dist/utils/dependencyExtractor.d.ts +28 -0
- package/dist/utils/dependencyExtractor.d.ts.map +1 -1
- package/dist/utils/dependencyExtractor.js +28 -1
- package/dist/utils/dependencyExtractor.js.map +1 -1
- package/dist/utils/errorMessage.d.ts +10 -0
- package/dist/utils/errorMessage.d.ts.map +1 -0
- package/dist/utils/errorMessage.js +12 -0
- package/dist/utils/errorMessage.js.map +1 -0
- package/dist/utils/fileDiscovery.d.ts +61 -2
- package/dist/utils/fileDiscovery.d.ts.map +1 -1
- package/dist/utils/fileDiscovery.js +131 -23
- package/dist/utils/fileDiscovery.js.map +1 -1
- package/dist/utils/reactDetection.d.ts +34 -5
- package/dist/utils/reactDetection.d.ts.map +1 -1
- package/dist/utils/reactDetection.js +73 -52
- package/dist/utils/reactDetection.js.map +1 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/workers/auditWorker.js +7 -3
- package/dist/workers/auditWorker.js.map +1 -1
- package/examples/.auditrc.example.json +0 -8
- package/examples/.auditrc.json +0 -11
- package/examples/.code-auditor.json +0 -2
- package/examples/nextjs.auditrc.json +0 -8
- package/examples/node-api.auditrc.json +0 -7
- package/examples/react.auditrc.json +0 -6
- package/examples/tolerant-solid.auditrc.json +0 -5
- package/package.json +14 -8
- package/plugin/.claude-plugin/manifest.json +16 -0
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/hooks/hooks.json +6 -2
- package/plugin/scripts/hook-audit.sh +41 -14
- package/plugin/scripts/hook-common.sh +50 -5
- package/plugin/scripts/hook-drift-check.sh +72 -0
- package/plugin/scripts/hook-self-audit.sh +17 -12
- package/plugin/skills/code-auditor/SKILL.md +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,1025 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spec 70 Item 4 (step 3) — the corpus-side reductions for the four receiver
|
|
3
|
+
* consumers, over the `receiver-activity` file fact + the `receiver-provenance`
|
|
4
|
+
* fixed point.
|
|
5
|
+
*
|
|
6
|
+
* The collapse makes each receiver consumer a corpus producer: it reads (a) a raw
|
|
7
|
+
* file fact extracted while the AST lived, and (b) the provenance fixed point, and
|
|
8
|
+
* re-derives the file's `buildProvenanceContext().dbProvenanced` with no AST via
|
|
9
|
+
* `classifyBuildProvenance`. This module holds the shared rehydration + the gate
|
|
10
|
+
* mirror those reductions need, so each consumer's `process` is a thin projection
|
|
11
|
+
* over pre-rehydrated provenance. The rehydrators are the inverse of the file
|
|
12
|
+
* producers' serialization: `evidenceFromFact`/`tsExtractFromFact` rebuild the
|
|
13
|
+
* `ProvenanceEvidence`/`TsWithinFileProvenanceExtract` the classify seam reads, and
|
|
14
|
+
* `rehydrateReceiverActivity` rebuilds the `Binding`/`R3Site` inputs
|
|
15
|
+
* `classifyBuildProvenance` folds R3 over.
|
|
16
|
+
*/
|
|
17
|
+
import picomatch from 'picomatch';
|
|
18
|
+
import { classifyBuildProvenance, evidenceFromFact, rehydrateWithinFileProvenance, bindingFromFact } from './receiverProvenance.js';
|
|
19
|
+
import { DEFAULT_SCHEMA_CONFIG } from '../analyzers/universal/schema/config.js';
|
|
20
|
+
import { identifyHandle } from '../analyzers/handleIdentification.js';
|
|
21
|
+
import { handleTypesForPackage } from '../analyzers/tsEcosystem.js';
|
|
22
|
+
import { parseSqlTables } from '../analyzers/universal/schema/codeAnalysis.js';
|
|
23
|
+
import { dialectForPackage } from '../languages/sql/dialectDetection.js';
|
|
24
|
+
import { parseSql, DEFAULT_SQL_DIALECT, extractTableNames, whereFacts, isWriteStatement, isMassWriteStatement, isUpsertStatement, whereColumnRefs, isDdlStatementKind, } from '../languages/sql/sqlAst.js';
|
|
25
|
+
import { rawInsertColumnsFromAst } from '../analyzers/universal/UniversalDataAccessAnalyzer.js';
|
|
26
|
+
import { describeUnprovenReceiver, resolveSpecifier, makeHeritageResolver } from '../analyzers/receiverResolution.js';
|
|
27
|
+
/** Assemble a `FileReceiverEnv` from the per-file fold and the resolution tail.
|
|
28
|
+
* Single constructor — the five consumers previously each built a near-identical
|
|
29
|
+
* nine-field literal, which `dry/similar-expression` flagged as the same object
|
|
30
|
+
* built five times. */
|
|
31
|
+
function fileReceiverEnv(fold, tail) {
|
|
32
|
+
const { dbProvenanced, bindings, bindingsByScope, goEnv, interfaceFields } = fold;
|
|
33
|
+
const { sqlDialect, declaredTypePackages, resolveImport, resolveHeritageField } = tail;
|
|
34
|
+
return { dbProvenanced, bindings, bindingsByScope, goEnv, interfaceFields, sqlDialect, declaredTypePackages, resolveImport, resolveHeritageField };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Build the single specifier-resolution seam the consumers thread into
|
|
38
|
+
* `identifyHandle`'s TS env: one `filesByPath` set derived once from the
|
|
39
|
+
* within-file facts, so the four specifier kinds (relative, tsconfig-`paths`,
|
|
40
|
+
* bare vendor, and the `@/`/`~/` fallback) all answer through `resolveSpecifier`
|
|
41
|
+
* (Spec 70 B1). Returns null when there is no project root to resolve against —
|
|
42
|
+
* the env's `resolveImport` stays undefined and the classifier abstains as it did
|
|
43
|
+
* before the seam was threaded.
|
|
44
|
+
*/
|
|
45
|
+
function makeSpecifierResolver(withinFacts, projectRoot, tsconfig) {
|
|
46
|
+
if (!projectRoot)
|
|
47
|
+
return null;
|
|
48
|
+
const filesByPath = new Set(withinFacts.map((f) => f.file));
|
|
49
|
+
// Memoize the resolution keyed on (source, importerPath) so a specifier that
|
|
50
|
+
// resolved once in the run is never re-probed. `resolveSpecifier`'s vendor arm
|
|
51
|
+
// walks up from the importer's directory doing `readFileSync`/`existsSync`
|
|
52
|
+
// probes, and the same bare import is resolved once per candidate that
|
|
53
|
+
// references it; without the cache that filesystem work is repeated for every
|
|
54
|
+
// candidate across every file. The importer is part of the key because the
|
|
55
|
+
// relative arm (and a monorepo's nested `node_modules`) resolve per-directory.
|
|
56
|
+
const cache = new Map();
|
|
57
|
+
return (source, importerPath) => {
|
|
58
|
+
const key = `${source}\u0000${importerPath}`;
|
|
59
|
+
const hit = cache.get(key);
|
|
60
|
+
if (hit !== undefined)
|
|
61
|
+
return hit;
|
|
62
|
+
const resolved = resolveSpecifier(source, importerPath, filesByPath, projectRoot, tsconfig);
|
|
63
|
+
cache.set(key, resolved);
|
|
64
|
+
return resolved;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// ── Rehydrators — fact → the corpus-side classify input, no translation ──────
|
|
68
|
+
/** Rehydrate one file's `receiver-activity` fact back to the three provenance
|
|
69
|
+
* inputs `classifyBuildProvenance` reads: the `Binding` map (`identifyHandle`'s
|
|
70
|
+
* declaration resolution), the `R3Site[]` (`applyR3FromSites`), and the DB-shaped
|
|
71
|
+
* activity set (`passesFileGate`'s `dbActivity` signal).
|
|
72
|
+
* @param fact - The serialized `receiver-activity` fact (may be absent).
|
|
73
|
+
* @returns The rehydrated bindings, R3 sites, and DB-activity set. */
|
|
74
|
+
export function rehydrateReceiverActivity(fact) {
|
|
75
|
+
if (!fact)
|
|
76
|
+
return { bindings: new Map(), bindingsByScope: new Map(), r3Sites: [], dbActivity: new Set() };
|
|
77
|
+
const bindings = new Map();
|
|
78
|
+
const bindingsByScope = new Map();
|
|
79
|
+
for (const b of fact.bindings) {
|
|
80
|
+
const binding = bindingFromFact(b);
|
|
81
|
+
// First wins (fact order == declaration order) — the flat map matches the
|
|
82
|
+
// legacy `buildBindingEnv` collapse for scope-agnostic consumers.
|
|
83
|
+
if (!bindings.has(b.name))
|
|
84
|
+
bindings.set(b.name, binding);
|
|
85
|
+
const scope = binding.scope ?? 0;
|
|
86
|
+
let byScope = bindingsByScope.get(b.name);
|
|
87
|
+
if (!byScope) {
|
|
88
|
+
byScope = new Map();
|
|
89
|
+
bindingsByScope.set(b.name, byScope);
|
|
90
|
+
}
|
|
91
|
+
if (!byScope.has(scope))
|
|
92
|
+
byScope.set(scope, binding);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
bindings,
|
|
96
|
+
bindingsByScope,
|
|
97
|
+
r3Sites: fact.r3Sites.map((s) => ({
|
|
98
|
+
root: s.root,
|
|
99
|
+
receiver: s.receiver,
|
|
100
|
+
method: s.method,
|
|
101
|
+
sqlArgument: s.sqlArgument,
|
|
102
|
+
thisField: s.thisField,
|
|
103
|
+
thisHeritage: s.thisHeritage,
|
|
104
|
+
})),
|
|
105
|
+
dbActivity: new Set(fact.dbActivity),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** Rehydrate the `receiver-provenance` fact's `files` back to a per-file seed
|
|
109
|
+
* map — the exact `FileProvenance[file]` the legacy `file.receiverProvenance`
|
|
110
|
+
* carried, keyed by file path so a consumer can look up its seed.
|
|
111
|
+
* @param fact - The serialized `receiver-provenance` fixed point.
|
|
112
|
+
* @returns A per-file map of provenanced-name → evidence. */
|
|
113
|
+
export function rehydrateReceiverProvenance(fact) {
|
|
114
|
+
const byFile = new Map();
|
|
115
|
+
for (const f of fact.files) {
|
|
116
|
+
byFile.set(f.file, new Map(f.provenance.map((e) => [e.identifier, evidenceFromFact(e)])));
|
|
117
|
+
}
|
|
118
|
+
return byFile;
|
|
119
|
+
}
|
|
120
|
+
/** Rehydrate the TS-family `within-file-provenance` facts back to a per-file
|
|
121
|
+
* `TsWithinFileProvenanceExtract` map (Go facts are skipped — the receiver
|
|
122
|
+
* consumers are TS-family-only).
|
|
123
|
+
* @param withinFacts - The `within-file-provenance` facts (TS-family + Go).
|
|
124
|
+
* @returns A per-file map of rehydrated `TsWithinFileProvenanceExtract` (Go skipped). */
|
|
125
|
+
export function rehydrateWithinTsExtracts(withinFacts) {
|
|
126
|
+
const byFile = new Map();
|
|
127
|
+
for (const fact of withinFacts) {
|
|
128
|
+
if (fact.format === 'go')
|
|
129
|
+
continue;
|
|
130
|
+
const rehydrated = rehydrateWithinFileProvenance(fact);
|
|
131
|
+
if (rehydrated.kind === 'ts')
|
|
132
|
+
byFile.set(fact.file, rehydrated.projection);
|
|
133
|
+
}
|
|
134
|
+
return byFile;
|
|
135
|
+
}
|
|
136
|
+
/** Rehydrate the Go `within-file-provenance` facts back to a per-file
|
|
137
|
+
* `GoWithinFileProvenanceExtract` map (TS facts are skipped). The Go extract is
|
|
138
|
+
* the binding + import env the Go arm of `identifyHandle` reads — `data-access-calls`
|
|
139
|
+
* is the one receiver consumer that runs for the `go` format, so its corpus
|
|
140
|
+
* producer needs the Go extracts in addition to the TS ones.
|
|
141
|
+
* @param withinFacts - The `within-file-provenance` facts (TS-family + Go).
|
|
142
|
+
* @returns A per-file map of rehydrated `GoWithinFileProvenanceExtract` (TS skipped). */
|
|
143
|
+
export function rehydrateWithinGoExtracts(withinFacts) {
|
|
144
|
+
const byFile = new Map();
|
|
145
|
+
for (const fact of withinFacts) {
|
|
146
|
+
if (fact.format !== 'go')
|
|
147
|
+
continue;
|
|
148
|
+
const rehydrated = rehydrateWithinFileProvenance(fact);
|
|
149
|
+
if (rehydrated.kind === 'go')
|
|
150
|
+
byFile.set(fact.file, rehydrated.projection);
|
|
151
|
+
}
|
|
152
|
+
return byFile;
|
|
153
|
+
}
|
|
154
|
+
/** Re-fold one file's DB-receiver environment from the rehydrated within-file
|
|
155
|
+
* extracts + the cross-file seed — the shared setup for the `data-access-calls`
|
|
156
|
+
* and `unproven-query-receivers` consumers. Go: the seed is the provenanced set
|
|
157
|
+
* and the extract supplies the binding/import env. TS: `classifyBuildProvenance`
|
|
158
|
+
* folds the seed + activity R3 sites + function wrappers into `dbProvenanced`,
|
|
159
|
+
* and the activity supplies the bindings. */
|
|
160
|
+
function foldReceiverEnvironment(opts) {
|
|
161
|
+
const { file, isGo, tsExtracts, goExtracts, seeds, activityByFile, sqlDialect } = opts;
|
|
162
|
+
if (isGo) {
|
|
163
|
+
const seed = seeds.get(file) ?? new Map();
|
|
164
|
+
const goExtract = goExtracts.get(file);
|
|
165
|
+
return {
|
|
166
|
+
dbProvenanced: seed,
|
|
167
|
+
bindings: new Map(),
|
|
168
|
+
bindingsByScope: new Map(),
|
|
169
|
+
goEnv: {
|
|
170
|
+
provenance: seed,
|
|
171
|
+
bindings: goExtract?.bindings ?? new Map(),
|
|
172
|
+
imports: goExtract?.imports ?? new Map(),
|
|
173
|
+
},
|
|
174
|
+
interfaceFields: undefined,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const extract = tsExtracts.get(file);
|
|
178
|
+
const activity = rehydrateReceiverActivity(activityByFile.get(file));
|
|
179
|
+
return {
|
|
180
|
+
dbProvenanced: extract
|
|
181
|
+
? classifyBuildProvenance(extract, seeds.get(file) ?? new Map(), activity.bindings, activity.r3Sites, sqlDialect)
|
|
182
|
+
: new Map(),
|
|
183
|
+
bindings: activity.bindings,
|
|
184
|
+
bindingsByScope: activity.bindingsByScope,
|
|
185
|
+
goEnv: undefined,
|
|
186
|
+
interfaceFields: extract?.interfaceFields,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// ── The gate mirror ──────────────────────────────────────────────────────────
|
|
190
|
+
/**
|
|
191
|
+
* The corpus-side mirror of `passesFileGate` for `mode !== 'names'` (the
|
|
192
|
+
* producers always build `mode: 'hybrid'`). The `names` arm never runs, and
|
|
193
|
+
* `hasSqlTag` — the one input the corpus producer cannot re-derive (it scans
|
|
194
|
+
* source text) — arrives pre-extracted in the raw fact. The glob + provenance +
|
|
195
|
+
* activity arms are byte-identical to the legacy gate.
|
|
196
|
+
*/
|
|
197
|
+
function passesFileGateRehydrated(filePath, hasSqlTag, dbProvenanced, dbActivity) {
|
|
198
|
+
const gateGlobs = DEFAULT_SCHEMA_CONFIG.fileGateGlobs ?? ['**/*.sql', '**/migrations/**'];
|
|
199
|
+
if (gateGlobs.some((glob) => picomatch.isMatch(filePath, glob)))
|
|
200
|
+
return true;
|
|
201
|
+
if (dbProvenanced.size > 0)
|
|
202
|
+
return true;
|
|
203
|
+
if (dbActivity.size > 0)
|
|
204
|
+
return true;
|
|
205
|
+
return hasSqlTag;
|
|
206
|
+
}
|
|
207
|
+
// ── `query-sites` reduction ──────────────────────────────────────────────────
|
|
208
|
+
/**
|
|
209
|
+
* The corpus `query-sites` producer: re-derive each file's gate (glob ||
|
|
210
|
+
* dbProvenanced || dbActivity || hasSqlTag) from the raw `query-site-candidates`
|
|
211
|
+
* fact + the provenance fixed point, and emit the sites of the files that pass.
|
|
212
|
+
*
|
|
213
|
+
* A file's `dbProvenanced` is re-derived by `classifyBuildProvenance` from its
|
|
214
|
+
* within-file extract, its cross-file seed (`receiver-provenance`), and its
|
|
215
|
+
* `receiver-activity` inputs. Files are iterated in the raw fact's (file-sorted)
|
|
216
|
+
* order, so the emitted site array — and every finding derived from it — is
|
|
217
|
+
* byte-identical to the legacy gated extraction.
|
|
218
|
+
*
|
|
219
|
+
* @param candidates the raw `query-site-candidates` facts (one per TS-family file)
|
|
220
|
+
* @param withinFacts the `within-file-provenance` facts (TS-family)
|
|
221
|
+
* @param provenance the `receiver-provenance` fixed point
|
|
222
|
+
* @param activityFacts the `receiver-activity` facts
|
|
223
|
+
* @param sqlDialect the corpus's named dialect, or null to skip R3
|
|
224
|
+
* @returns the classified query-site facts (one per admitted TS-family site)
|
|
225
|
+
*/
|
|
226
|
+
export function classifyQuerySites(candidates, withinFacts, provenance, activityFacts, sqlDialect) {
|
|
227
|
+
const extracts = rehydrateWithinTsExtracts(withinFacts);
|
|
228
|
+
const seeds = rehydrateReceiverProvenance(provenance);
|
|
229
|
+
const activityByFile = new Map(activityFacts.map((f) => [f.file, f]));
|
|
230
|
+
const out = [];
|
|
231
|
+
for (const cand of candidates) {
|
|
232
|
+
const extract = extracts.get(cand.file);
|
|
233
|
+
// A file with no within-file extract (should not happen — both facts are
|
|
234
|
+
// TS-family, emitted for the same files) cannot re-derive provenance; its
|
|
235
|
+
// gate falls through to dbActivity/hasSqlTag/glob, matching a file with no
|
|
236
|
+
// within-file DB seed.
|
|
237
|
+
const activity = rehydrateReceiverActivity(activityByFile.get(cand.file));
|
|
238
|
+
const dbProvenanced = extract
|
|
239
|
+
? classifyBuildProvenance(extract, seeds.get(cand.file) ?? new Map(), activity.bindings, activity.r3Sites, sqlDialect)
|
|
240
|
+
: new Map();
|
|
241
|
+
if (passesFileGateRehydrated(cand.file, cand.hasSqlTag, dbProvenanced, activity.dbActivity)) {
|
|
242
|
+
out.push(...cand.sites);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
// ── `schema-usage` reduction ─────────────────────────────────────────────────
|
|
248
|
+
/** True when `loc` falls inside the span [start, end] (all 1-based line/column). */
|
|
249
|
+
function contains(start, end, loc) {
|
|
250
|
+
const afterStart = start.line < loc.line || (start.line === loc.line && start.column <= loc.column);
|
|
251
|
+
const beforeEnd = end.line > loc.line || (end.line === loc.line && end.column >= loc.column);
|
|
252
|
+
return afterStart && beforeEnd;
|
|
253
|
+
}
|
|
254
|
+
/** True when `a` starts at or after `b` — the "innermost wins" tiebreak. */
|
|
255
|
+
function startsAtOrAfter(a, b) {
|
|
256
|
+
return a.line > b.line || (a.line === b.line && a.column >= b.column);
|
|
257
|
+
}
|
|
258
|
+
/** The corpus-side mirror of `dialectForEvidence` (private in provenance.ts):
|
|
259
|
+
* the SQL dialect a DB-driver package's evidence names, or null. */
|
|
260
|
+
function dialectForEvidence(evidence) {
|
|
261
|
+
if (!evidence?.packageName)
|
|
262
|
+
return null;
|
|
263
|
+
return dialectForPackage(evidence.packageName);
|
|
264
|
+
}
|
|
265
|
+
/** The corpus-side mirror of `resolveSiteDialect`'s member arm (provenance.ts):
|
|
266
|
+
* the receiver text's package, then each dotted segment, first non-null wins. */
|
|
267
|
+
function resolveSiteDialectFromReceiver(receiver, dbProvenanced) {
|
|
268
|
+
if (!receiver)
|
|
269
|
+
return null;
|
|
270
|
+
for (const candidate of [receiver, ...receiver.split('.')]) {
|
|
271
|
+
const dialect = dialectForEvidence(dbProvenanced.get(candidate));
|
|
272
|
+
if (dialect)
|
|
273
|
+
return dialect;
|
|
274
|
+
}
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* The corpus-side mirror of `findClosestNodeAt` + `findEnclosingFunctionIdentity`
|
|
279
|
+
* (the legacy re-home), over the projected spans. For an in-function reference
|
|
280
|
+
* the identity is the innermost enclosing function (the containing span with the
|
|
281
|
+
* latest start); for a top-level reference it is the `string_fragment` containing
|
|
282
|
+
* the reference — the deepest node `findClosestNodeAt` returns for a table name
|
|
283
|
+
* inside a SQL string — whose start becomes the coordinate.
|
|
284
|
+
*/
|
|
285
|
+
function rehomeReference(ref, filePath, functions, stringFragments) {
|
|
286
|
+
const loc = ref.location;
|
|
287
|
+
let fn = null;
|
|
288
|
+
for (const f of functions) {
|
|
289
|
+
const start = { line: f.startLine, column: f.startColumn };
|
|
290
|
+
if (contains(start, { line: f.endLine, column: f.endColumn }, loc) &&
|
|
291
|
+
(fn === null || startsAtOrAfter(start, { line: fn.startLine, column: fn.startColumn }))) {
|
|
292
|
+
fn = f;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (fn) {
|
|
296
|
+
return {
|
|
297
|
+
tableName: ref.table,
|
|
298
|
+
filePath,
|
|
299
|
+
functionName: fn.name,
|
|
300
|
+
functionStartLine: fn.startLine,
|
|
301
|
+
functionStartColumn: fn.startColumn,
|
|
302
|
+
usageType: ref.type,
|
|
303
|
+
line: loc.line,
|
|
304
|
+
column: loc.column,
|
|
305
|
+
rawQuery: ref.context,
|
|
306
|
+
origin: ref.origin,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
let frag = null;
|
|
310
|
+
for (const fr of stringFragments) {
|
|
311
|
+
const start = { line: fr.startLine, column: fr.startColumn };
|
|
312
|
+
if (contains(start, { line: fr.endLine, column: fr.endColumn }, loc) &&
|
|
313
|
+
(frag === null || startsAtOrAfter(start, { line: frag.startLine, column: frag.startColumn }))) {
|
|
314
|
+
frag = fr;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
tableName: ref.table,
|
|
319
|
+
filePath,
|
|
320
|
+
functionName: 'top-level',
|
|
321
|
+
functionStartLine: frag?.startLine ?? null,
|
|
322
|
+
functionStartColumn: frag?.startColumn ?? null,
|
|
323
|
+
usageType: ref.type,
|
|
324
|
+
line: loc.line,
|
|
325
|
+
column: loc.column,
|
|
326
|
+
rawQuery: ref.context,
|
|
327
|
+
origin: ref.origin,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* The corpus-side mirror of `dbCallVerdict`'s provenance-dependent admission
|
|
332
|
+
* (`identifyHandle`). The raw producer already applied the structural gates
|
|
333
|
+
* (callee shape, method gate, root gate, resolvable SQL); this re-folds the
|
|
334
|
+
* handle verdict over the re-derived `dbProvenanced` + rehydrated bindings and
|
|
335
|
+
* drops `not-handle` (and, for a bare-identifier call, a name that is neither
|
|
336
|
+
* provenanced nor type-annotated). Returns the verdict plus the site dialect the
|
|
337
|
+
* caller's `parseSqlTables` needs, or null when the call is not admitted.
|
|
338
|
+
*/
|
|
339
|
+
function admitDbCall(call, env) {
|
|
340
|
+
const { dbProvenanced, bindings, sqlDialect, interfaceFields, declaredTypePackages, resolveImport, resolveHeritageField } = env;
|
|
341
|
+
const siteDialect = call.calleeType === 'identifier'
|
|
342
|
+
? dialectForEvidence(dbProvenanced.get(call.name))
|
|
343
|
+
: resolveSiteDialectFromReceiver(call.receiver, dbProvenanced);
|
|
344
|
+
const dialect = siteDialect ?? sqlDialect ?? null;
|
|
345
|
+
const resolutionEnv = { provenance: dbProvenanced, bindings, interfaceFields, declaredTypePackages, resolveImport, resolveHeritageField, adapter: undefined, sourceCode: '' };
|
|
346
|
+
const facts = {
|
|
347
|
+
imports: new Map(),
|
|
348
|
+
typeAnnotations: new Map(),
|
|
349
|
+
bindings: new Map(),
|
|
350
|
+
withinFileProvenance: new Map(),
|
|
351
|
+
sqlDialect: dialect,
|
|
352
|
+
resolution: { dialect: 'ts', env: resolutionEnv },
|
|
353
|
+
};
|
|
354
|
+
if (call.calleeType === 'identifier') {
|
|
355
|
+
const binding = bindings.get(call.name);
|
|
356
|
+
const isProvenanced = dbProvenanced.has(call.name);
|
|
357
|
+
const isTypeAnnotated = !!binding && !!binding.typeText;
|
|
358
|
+
// A named import from a manifest DB package is a DB *signal* even when the
|
|
359
|
+
// name isn't a handle — admit it so `identifyHandle` proves `not-handle`
|
|
360
|
+
// rather than dropping the site for want of evidence (Spec 70).
|
|
361
|
+
const isDbPackageImport = !!binding && binding.kind === 'import' && handleTypesForPackage(binding.source ?? '') !== undefined;
|
|
362
|
+
if (!isProvenanced && !isTypeAnnotated && !isDbPackageImport)
|
|
363
|
+
return null;
|
|
364
|
+
const verdict = identifyHandle({
|
|
365
|
+
format: 'typescript',
|
|
366
|
+
root: call.name,
|
|
367
|
+
receiver: call.name,
|
|
368
|
+
method: call.name,
|
|
369
|
+
sqlArgument: call.sqlArgument,
|
|
370
|
+
thisField: false,
|
|
371
|
+
}, facts);
|
|
372
|
+
return verdict.kind === 'not-handle' ? null : { dialect };
|
|
373
|
+
}
|
|
374
|
+
const verdict = identifyHandle({
|
|
375
|
+
format: 'typescript',
|
|
376
|
+
root: call.root,
|
|
377
|
+
receiver: call.receiver ?? call.root,
|
|
378
|
+
method: call.method,
|
|
379
|
+
sqlArgument: call.sqlArgument,
|
|
380
|
+
thisField: call.thisField,
|
|
381
|
+
}, facts);
|
|
382
|
+
return verdict.kind === 'not-handle' ? null : { dialect };
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* The corpus `schema-usage` producer: re-derive each file's gate and its
|
|
386
|
+
* `dbProvenanced` from the raw `schema-usage-candidates` fact + the provenance
|
|
387
|
+
* fixed point, then re-admit and re-home the provenance-dependent references
|
|
388
|
+
* (tagged-template + DB-call) and append the provenance-free references the raw
|
|
389
|
+
* producer already re-homed (ORM / query-builder / collection-adapter).
|
|
390
|
+
*
|
|
391
|
+
* The emitted array is the legacy `extractSchemaUsage` output, byte-identical:
|
|
392
|
+
* strategy (1) tagged, (2) DB-call, (4) ORM, (5) query-builder, (6)
|
|
393
|
+
* collection-adapter — in that order, gated the same way, re-homed the same way.
|
|
394
|
+
*
|
|
395
|
+
* @param candidates the raw `schema-usage-candidates` facts (one per TS-family file)
|
|
396
|
+
* @param resolution the per-corpus resolution inputs (facts + dialect/project tail)
|
|
397
|
+
* @returns the classified schema-usage facts (strategies 1/2/4/5/6, in order)
|
|
398
|
+
*/
|
|
399
|
+
export function classifySchemaUsage(candidates, resolution) {
|
|
400
|
+
const { withinFacts, provenance, activityFacts, sqlDialect, declaredTypePackages, projectRoot, tsconfig } = resolution;
|
|
401
|
+
const extracts = rehydrateWithinTsExtracts(withinFacts);
|
|
402
|
+
const seeds = rehydrateReceiverProvenance(provenance);
|
|
403
|
+
const activityByFile = new Map(activityFacts.map((f) => [f.file, f]));
|
|
404
|
+
const resolver = makeSpecifierResolver(withinFacts, projectRoot, tsconfig);
|
|
405
|
+
const heritageResolver = makeHeritageResolver(projectRoot, declaredTypePackages) ?? undefined;
|
|
406
|
+
const out = [];
|
|
407
|
+
for (const cand of candidates) {
|
|
408
|
+
const extract = extracts.get(cand.file);
|
|
409
|
+
const activity = rehydrateReceiverActivity(activityByFile.get(cand.file));
|
|
410
|
+
const dbProvenanced = extract
|
|
411
|
+
? classifyBuildProvenance(extract, seeds.get(cand.file) ?? new Map(), activity.bindings, activity.r3Sites, sqlDialect)
|
|
412
|
+
: new Map();
|
|
413
|
+
if (!passesFileGateRehydrated(cand.file, cand.hasSqlTag, dbProvenanced, activity.dbActivity)) {
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
const sourceCode = cand.sourceCode;
|
|
417
|
+
const resolveImport = resolver ? (source) => resolver(source, cand.file) : undefined;
|
|
418
|
+
const env = fileReceiverEnv({ dbProvenanced, bindings: activity.bindings, bindingsByScope: activity.bindingsByScope, goEnv: undefined, interfaceFields: extract?.interfaceFields }, { sqlDialect, declaredTypePackages, resolveImport, resolveHeritageField: heritageResolver });
|
|
419
|
+
// (1) Tagged-template SQL — re-admit by the tag's package dialect, parse.
|
|
420
|
+
for (const t of cand.tagged) {
|
|
421
|
+
const siteDialect = dialectForEvidence(dbProvenanced.get(t.tagName));
|
|
422
|
+
const dialect = siteDialect ?? sqlDialect ?? null;
|
|
423
|
+
const parsed = parseSqlTables(t.templateText, t.location, sourceCode, undefined, dialect, null);
|
|
424
|
+
for (const ref of parsed.references) {
|
|
425
|
+
out.push(rehomeReference(ref, cand.file, cand.functions, cand.stringFragments));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
// (2) DB-call patterns — re-admit via `identifyHandle`, then parse. An
|
|
429
|
+
// unresolved candidate (`sqlText === null`) contributes no table references
|
|
430
|
+
// here; its `unresolved` record is re-derived by `classifyUnresolvedQuerySites`.
|
|
431
|
+
for (const call of cand.dbCalls) {
|
|
432
|
+
if (call.sqlText === null)
|
|
433
|
+
continue;
|
|
434
|
+
const admitted = admitDbCall(call, env);
|
|
435
|
+
if (!admitted)
|
|
436
|
+
continue;
|
|
437
|
+
const parsed = parseSqlTables(call.sqlText, call.location, sourceCode, undefined, admitted.dialect, null);
|
|
438
|
+
for (const ref of parsed.references) {
|
|
439
|
+
out.push(rehomeReference(ref, cand.file, cand.functions, cand.stringFragments));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
// (4)(5)(6) ORM / query-builder / collection-adapter — re-homed raw-side.
|
|
443
|
+
out.push(...cand.ormRefs, ...cand.queryBuilderRefs, ...cand.collectionAdapterRefs);
|
|
444
|
+
}
|
|
445
|
+
return out;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Spec 70 1b — the corpus `unresolved-query` reduction. The legacy `schema-code`
|
|
449
|
+
* visitor emitted `checkUnresolvedQueries` for DB-calls `findTableReferences`
|
|
450
|
+
* admitted via `dbCallVerdict` (i.e. `identifyHandle` said "DB handle") but whose
|
|
451
|
+
* SQL argument was held in an unresolvable identifier. The collapse re-derives
|
|
452
|
+
* that surface with no AST: for each raw `schema-usage-candidates` fact, re-derive
|
|
453
|
+
* `dbProvenanced` (as `classifySchemaUsage` does), re-apply the file gate, then
|
|
454
|
+
* re-admit every `unresolved` candidate via `identifyHandle` — dropping any that
|
|
455
|
+
* are not DB handles — and emit the `unresolved-query` site record.
|
|
456
|
+
*
|
|
457
|
+
* @param candidates the raw `schema-usage-candidates` facts (one per TS-family file)
|
|
458
|
+
* @param resolution the per-corpus resolution inputs (facts + dialect/project tail)
|
|
459
|
+
* @returns the unresolved-query site records re-admitted via `identifyHandle`
|
|
460
|
+
*/
|
|
461
|
+
export function classifyUnresolvedQuerySites(candidates, resolution) {
|
|
462
|
+
const { withinFacts, provenance, activityFacts, sqlDialect, declaredTypePackages, projectRoot, tsconfig } = resolution;
|
|
463
|
+
const extracts = rehydrateWithinTsExtracts(withinFacts);
|
|
464
|
+
const seeds = rehydrateReceiverProvenance(provenance);
|
|
465
|
+
const activityByFile = new Map(activityFacts.map((f) => [f.file, f]));
|
|
466
|
+
const resolver = makeSpecifierResolver(withinFacts, projectRoot, tsconfig);
|
|
467
|
+
const heritageResolver = makeHeritageResolver(projectRoot, declaredTypePackages) ?? undefined;
|
|
468
|
+
const out = [];
|
|
469
|
+
for (const cand of candidates) {
|
|
470
|
+
const extract = extracts.get(cand.file);
|
|
471
|
+
const activity = rehydrateReceiverActivity(activityByFile.get(cand.file));
|
|
472
|
+
const dbProvenanced = extract
|
|
473
|
+
? classifyBuildProvenance(extract, seeds.get(cand.file) ?? new Map(), activity.bindings, activity.r3Sites, sqlDialect)
|
|
474
|
+
: new Map();
|
|
475
|
+
if (!passesFileGateRehydrated(cand.file, cand.hasSqlTag, dbProvenanced, activity.dbActivity)) {
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
const resolveImport = resolver ? (source) => resolver(source, cand.file) : undefined;
|
|
479
|
+
const env = fileReceiverEnv({ dbProvenanced, bindings: activity.bindings, bindingsByScope: activity.bindingsByScope, goEnv: undefined, interfaceFields: extract?.interfaceFields }, { sqlDialect, declaredTypePackages, resolveImport, resolveHeritageField: heritageResolver });
|
|
480
|
+
for (const call of cand.dbCalls) {
|
|
481
|
+
if (call.unresolved === null)
|
|
482
|
+
continue;
|
|
483
|
+
// Re-admit via `identifyHandle` — mirror the legacy `dbCallVerdict` gate so
|
|
484
|
+
// a non-DB receiver (`page.$`, `$('.foo')`) never emits `unresolved-query`.
|
|
485
|
+
const admitted = admitDbCall(call, env);
|
|
486
|
+
if (!admitted)
|
|
487
|
+
continue;
|
|
488
|
+
out.push({ file: cand.file, identifier: call.unresolved.identifier, location: call.unresolved.location });
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return out;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Spec 70 R2 — the corpus `unparseable` reduction. The legacy `schema-code`
|
|
495
|
+
* visitor emitted `checkUnparseableSql` for every DB-call / tagged-template SQL
|
|
496
|
+
* argument `findTableReferences` admitted but whose static text the named
|
|
497
|
+
* dialect could not parse (e.g. SQLite `PRAGMA`/`VACUUM`/`ANALYZE`). The collapse
|
|
498
|
+
* re-derives that surface with no AST: for each raw `schema-usage-candidates`
|
|
499
|
+
* fact, re-derive `dbProvenanced` (as `classifySchemaUsage` does), re-apply the
|
|
500
|
+
* file gate, then re-admit and re-parse every tagged template and DB-call
|
|
501
|
+
* candidate — collecting `parseSqlTables().unparseable` (which
|
|
502
|
+
* `classifySchemaUsage` discards) instead of its references. This is the
|
|
503
|
+
* `unparseable` sibling of {@link classifyUnresolvedQuerySites} (the
|
|
504
|
+
* `unresolved` half): the same re-derivation shape, a distinct output record.
|
|
505
|
+
*
|
|
506
|
+
* @param candidates the raw `schema-usage-candidates` facts (one per TS-family file)
|
|
507
|
+
* @param resolution the per-corpus resolution inputs (facts + dialect/project tail)
|
|
508
|
+
* @returns the unparseable-SQL records re-admitted via `identifyHandle`, each
|
|
509
|
+
* stamped with its `file` (the legacy visitor emitted `checkUnparseableSql`
|
|
510
|
+
* per-file, so the caller must be able to re-group by file)
|
|
511
|
+
*/
|
|
512
|
+
export function classifyUnparseableSql(candidates, resolution) {
|
|
513
|
+
const { withinFacts, provenance, activityFacts, sqlDialect, sqlDialectReason, declaredTypePackages, projectRoot, tsconfig } = resolution;
|
|
514
|
+
const extracts = rehydrateWithinTsExtracts(withinFacts);
|
|
515
|
+
const seeds = rehydrateReceiverProvenance(provenance);
|
|
516
|
+
const activityByFile = new Map(activityFacts.map((f) => [f.file, f]));
|
|
517
|
+
const resolver = makeSpecifierResolver(withinFacts, projectRoot, tsconfig);
|
|
518
|
+
const heritageResolver = makeHeritageResolver(projectRoot, declaredTypePackages) ?? undefined;
|
|
519
|
+
const out = [];
|
|
520
|
+
for (const cand of candidates) {
|
|
521
|
+
const extract = extracts.get(cand.file);
|
|
522
|
+
const activity = rehydrateReceiverActivity(activityByFile.get(cand.file));
|
|
523
|
+
const dbProvenanced = extract
|
|
524
|
+
? classifyBuildProvenance(extract, seeds.get(cand.file) ?? new Map(), activity.bindings, activity.r3Sites, sqlDialect)
|
|
525
|
+
: new Map();
|
|
526
|
+
if (!passesFileGateRehydrated(cand.file, cand.hasSqlTag, dbProvenanced, activity.dbActivity)) {
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
const sourceCode = cand.sourceCode;
|
|
530
|
+
const resolveImport = resolver ? (source) => resolver(source, cand.file) : undefined;
|
|
531
|
+
const env = fileReceiverEnv({ dbProvenanced, bindings: activity.bindings, bindingsByScope: activity.bindingsByScope, goEnv: undefined, interfaceFields: extract?.interfaceFields }, { sqlDialect, declaredTypePackages, resolveImport, resolveHeritageField: heritageResolver });
|
|
532
|
+
// (1) Tagged-template SQL — re-admit by the tag's package dialect, parse.
|
|
533
|
+
for (const t of cand.tagged) {
|
|
534
|
+
const siteDialect = dialectForEvidence(dbProvenanced.get(t.tagName));
|
|
535
|
+
const dialect = siteDialect ?? sqlDialect ?? null;
|
|
536
|
+
const parsed = parseSqlTables(t.templateText, t.location, sourceCode, undefined, dialect, sqlDialectReason ?? null);
|
|
537
|
+
for (const u of parsed.unparseable)
|
|
538
|
+
out.push({ ...u, file: cand.file });
|
|
539
|
+
}
|
|
540
|
+
// (2) DB-call patterns — re-admit via `identifyHandle`, then parse. An
|
|
541
|
+
// unresolved candidate (`sqlText === null`) contributes no unparseable record
|
|
542
|
+
// here; its `unresolved` record is re-derived by `classifyUnresolvedQuerySites`.
|
|
543
|
+
for (const call of cand.dbCalls) {
|
|
544
|
+
if (call.sqlText === null)
|
|
545
|
+
continue;
|
|
546
|
+
const admitted = admitDbCall(call, env);
|
|
547
|
+
if (!admitted)
|
|
548
|
+
continue;
|
|
549
|
+
const parsed = parseSqlTables(call.sqlText, call.location, sourceCode, undefined, admitted.dialect, sqlDialectReason ?? null);
|
|
550
|
+
for (const u of parsed.unparseable)
|
|
551
|
+
out.push({ ...u, file: cand.file });
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return out;
|
|
555
|
+
}
|
|
556
|
+
/** Project a candidate's `handle*` fields into the corpus-side `HandleIdentity`.
|
|
557
|
+
* The two candidates differ only in `format` (data-access carries the raw
|
|
558
|
+
* producer's format; loop-query is TS-only) and which field is the handle SQL
|
|
559
|
+
* argument (`handleSqlArg` vs `sqlArg`) — everything else is the shared shape. */
|
|
560
|
+
function handleIdentity(source, format, sqlArg) {
|
|
561
|
+
return {
|
|
562
|
+
format,
|
|
563
|
+
calleeType: source.handleCalleeType,
|
|
564
|
+
name: source.handleName,
|
|
565
|
+
root: source.handleRoot,
|
|
566
|
+
receiver: source.handleReceiver,
|
|
567
|
+
method: source.handleMethod,
|
|
568
|
+
thisField: source.handleThisField,
|
|
569
|
+
thisHeritage: source.handleThisHeritage,
|
|
570
|
+
sqlArg,
|
|
571
|
+
siteReceiver: source.handleSiteReceiver,
|
|
572
|
+
scope: source.handleRootScope ?? 0,
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
/** The identity of one data-access-call candidate (the `handle*` fields). */
|
|
576
|
+
function dataAccessIdentity(cand) {
|
|
577
|
+
return handleIdentity(cand, cand.format, cand.handleSqlArg);
|
|
578
|
+
}
|
|
579
|
+
/** The identity of one loop-query candidate (TS-only; `sqlArg` is the handle
|
|
580
|
+
* SQL-argument source, `handleSiteReceiver` the site-dialect receiver). */
|
|
581
|
+
function loopQueryIdentity(cand) {
|
|
582
|
+
return handleIdentity(cand, 'typescript', cand.sqlArg);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* The corpus-side mirror of `handleVerdictForCall` — re-fold `identifyHandle`
|
|
586
|
+
* over the re-derived `dbProvenanced` + rehydrated bindings (TS) or the Go
|
|
587
|
+
* resolution env (Go). The raw producer already applied every structural gate
|
|
588
|
+
* (callee shape, method/root gate, template → enclosing-call resolution), so the
|
|
589
|
+
* identity is already narrowed to a query-shaped call; what remains is the
|
|
590
|
+
* provenance-dependent gate the identifier arm alone carries (a bare name that is
|
|
591
|
+
* neither provenanced nor type-annotated is rejected before `identifyHandle`) and
|
|
592
|
+
* the verdict itself. Returns the tri-state verdict, or null when the shape is
|
|
593
|
+
* not query-shaped.
|
|
594
|
+
*/
|
|
595
|
+
/** A stable string key for one candidate's handle identity, for the shared
|
|
596
|
+
* verdict cache. `sqlArg` and `siteReceiver` are part of the key because both
|
|
597
|
+
* feed `identifyHandle` (the SQL-argument parse and the site-dialect parse). */
|
|
598
|
+
function handleIdentityKey(id) {
|
|
599
|
+
return [
|
|
600
|
+
id.format,
|
|
601
|
+
id.calleeType ?? '',
|
|
602
|
+
id.name ?? '',
|
|
603
|
+
id.root ?? '',
|
|
604
|
+
id.receiver ?? '',
|
|
605
|
+
id.method ?? '',
|
|
606
|
+
id.thisField ? '1' : '0',
|
|
607
|
+
id.thisHeritage ?? '',
|
|
608
|
+
id.sqlArg ?? '',
|
|
609
|
+
id.siteReceiver ?? '',
|
|
610
|
+
String(id.scope),
|
|
611
|
+
].join('\u0000');
|
|
612
|
+
}
|
|
613
|
+
function reFoldHandleVerdict(id, env, file, verdictCache) {
|
|
614
|
+
const key = verdictCache ? `${file}\u0000${handleIdentityKey(id)}` : null;
|
|
615
|
+
if (key !== null) {
|
|
616
|
+
const hit = verdictCache.get(key);
|
|
617
|
+
if (hit !== undefined)
|
|
618
|
+
return hit;
|
|
619
|
+
}
|
|
620
|
+
const result = foldHandleVerdict(id, env);
|
|
621
|
+
if (key !== null)
|
|
622
|
+
verdictCache.set(key, result);
|
|
623
|
+
return result;
|
|
624
|
+
}
|
|
625
|
+
function foldHandleVerdict(id, env) {
|
|
626
|
+
const { dbProvenanced, bindings, bindingsByScope, goEnv, sqlDialect, interfaceFields, declaredTypePackages, resolveImport, resolveHeritageField } = env;
|
|
627
|
+
if (id.format === 'go') {
|
|
628
|
+
if (!goEnv || id.calleeType !== 'member' || !id.root || !id.method)
|
|
629
|
+
return null;
|
|
630
|
+
return identifyHandle({
|
|
631
|
+
format: 'go',
|
|
632
|
+
root: id.root,
|
|
633
|
+
receiver: id.receiver ?? id.root,
|
|
634
|
+
method: id.method,
|
|
635
|
+
sqlArgument: id.sqlArg,
|
|
636
|
+
thisField: false,
|
|
637
|
+
}, {
|
|
638
|
+
imports: new Map(),
|
|
639
|
+
typeAnnotations: new Map(),
|
|
640
|
+
bindings: new Map(),
|
|
641
|
+
withinFileProvenance: new Map(),
|
|
642
|
+
sqlDialect: sqlDialect ?? null,
|
|
643
|
+
resolution: { dialect: 'go', env: goEnv },
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
if (id.calleeType === 'identifier') {
|
|
647
|
+
const name = id.name;
|
|
648
|
+
if (!name)
|
|
649
|
+
return null;
|
|
650
|
+
const binding = bindings.get(name);
|
|
651
|
+
const isProvenanced = dbProvenanced.has(name);
|
|
652
|
+
const isTypeAnnotated = !!binding &&
|
|
653
|
+
(binding.kind === 'variable' || binding.kind === 'field' || binding.kind === 'parameter') &&
|
|
654
|
+
!!binding.typeText;
|
|
655
|
+
if (!isProvenanced && !isTypeAnnotated)
|
|
656
|
+
return null;
|
|
657
|
+
const dialect = dialectForEvidence(dbProvenanced.get(name)) ?? sqlDialect ?? null;
|
|
658
|
+
const resolutionEnv = { provenance: dbProvenanced, bindings, bindingsByScope, interfaceFields, declaredTypePackages, resolveImport, resolveHeritageField, adapter: undefined, sourceCode: '' };
|
|
659
|
+
return identifyHandle({
|
|
660
|
+
format: 'typescript',
|
|
661
|
+
root: name,
|
|
662
|
+
receiver: name,
|
|
663
|
+
method: name,
|
|
664
|
+
sqlArgument: id.sqlArg,
|
|
665
|
+
thisField: false,
|
|
666
|
+
scope: id.scope,
|
|
667
|
+
}, {
|
|
668
|
+
imports: new Map(),
|
|
669
|
+
typeAnnotations: new Map(),
|
|
670
|
+
bindings: new Map(),
|
|
671
|
+
withinFileProvenance: new Map(),
|
|
672
|
+
sqlDialect: dialect,
|
|
673
|
+
resolution: { dialect: 'ts', env: resolutionEnv },
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
if (id.calleeType === 'member') {
|
|
677
|
+
if (!id.root || !id.method)
|
|
678
|
+
return null;
|
|
679
|
+
const dialect = resolveSiteDialectFromReceiver(id.siteReceiver, dbProvenanced) ?? sqlDialect ?? null;
|
|
680
|
+
const resolutionEnv = { provenance: dbProvenanced, bindings, bindingsByScope, interfaceFields, declaredTypePackages, resolveImport, resolveHeritageField, adapter: undefined, sourceCode: '' };
|
|
681
|
+
return identifyHandle({
|
|
682
|
+
format: 'typescript',
|
|
683
|
+
root: id.root,
|
|
684
|
+
receiver: id.receiver ?? id.root,
|
|
685
|
+
method: id.method,
|
|
686
|
+
sqlArgument: id.sqlArg,
|
|
687
|
+
thisField: id.thisField,
|
|
688
|
+
thisHeritage: id.thisHeritage,
|
|
689
|
+
scope: id.scope,
|
|
690
|
+
}, {
|
|
691
|
+
imports: new Map(),
|
|
692
|
+
typeAnnotations: new Map(),
|
|
693
|
+
bindings: new Map(),
|
|
694
|
+
withinFileProvenance: new Map(),
|
|
695
|
+
sqlDialect: dialect,
|
|
696
|
+
resolution: { dialect: 'ts', env: resolutionEnv },
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
return null;
|
|
700
|
+
}
|
|
701
|
+
/** The corpus-side mirror of `classifyCallType` (private in the analyzer): a
|
|
702
|
+
* non-decision label — `sql` for a raw SQL query, `orm` for a query-builder
|
|
703
|
+
* shape, `unknown` otherwise. No rule reads it. */
|
|
704
|
+
function classifyCallType(isSqlQuery, isOrmCall) {
|
|
705
|
+
if (isSqlQuery)
|
|
706
|
+
return 'sql';
|
|
707
|
+
if (isOrmCall)
|
|
708
|
+
return 'orm';
|
|
709
|
+
return 'unknown';
|
|
710
|
+
}
|
|
711
|
+
/** The corpus-side mirror of `nextSymbol` (private in the analyzer): the next
|
|
712
|
+
* stable per-file symbol key for a (function, method) pair. */
|
|
713
|
+
function nextSymbol(fnName, method, ordinals) {
|
|
714
|
+
const base = `${fnName}:${method}`;
|
|
715
|
+
const ordinal = (ordinals.get(base) ?? 0) + 1;
|
|
716
|
+
ordinals.set(base, ordinal);
|
|
717
|
+
return ordinal > 1 ? `${base}:${ordinal}` : base;
|
|
718
|
+
}
|
|
719
|
+
/** Re-fold one candidate into a resolved query, mirroring `buildDatabaseCall`
|
|
720
|
+
* byte-identically over the pre-extracted provenance-free fields plus the
|
|
721
|
+
* already-re-folded handle verdict. */
|
|
722
|
+
function buildDataAccessCall(cand, verdict, dbProvenanced, sqlDialect, learnedWrappers) {
|
|
723
|
+
// A call_expression rediscovered via its template argument is dropped in favour
|
|
724
|
+
// of the template (path 2).
|
|
725
|
+
if (cand.skipCallForTemplateArg)
|
|
726
|
+
return null;
|
|
727
|
+
const sqlArg = cand.sqlArg;
|
|
728
|
+
// `resolveSiteDialect` reads the node's *own* callee — the `site*` identity —
|
|
729
|
+
// distinct from the handle verdict's enclosing-call identity.
|
|
730
|
+
const siteDialect = cand.siteCalleeType === 'identifier'
|
|
731
|
+
? cand.siteName
|
|
732
|
+
? dialectForEvidence(dbProvenanced.get(cand.siteName))
|
|
733
|
+
: null
|
|
734
|
+
: resolveSiteDialectFromReceiver(cand.siteReceiver, dbProvenanced);
|
|
735
|
+
const dialect = siteDialect ?? sqlDialect ?? null;
|
|
736
|
+
const parsed = sqlArg !== null ? parseSql(sqlArg, dialect ?? DEFAULT_SQL_DIALECT) : null;
|
|
737
|
+
const sqlOk = parsed && parsed.ok ? parsed : null;
|
|
738
|
+
// DDL statements (CREATE/ALTER/DROP/USE) are schema definition, not a
|
|
739
|
+
// row-level data-access query: they carry no rows to filter and no tenant
|
|
740
|
+
// predicate to check. A variable assignment holding a migration body
|
|
741
|
+
// (`const up = \`CREATE TABLE …\``) must not surface as a data-access call —
|
|
742
|
+
// schema is read separately by the `.sql` visitor and Durable Object DDL.
|
|
743
|
+
if (sqlOk && isDdlStatementKind(sqlOk.kind))
|
|
744
|
+
return null;
|
|
745
|
+
const isOrmCall = cand.isOrmCall;
|
|
746
|
+
const isTaggedSqlCall = cand.isTaggedSqlCall;
|
|
747
|
+
const handleAdmits = verdict !== null && verdict.kind !== 'not-handle';
|
|
748
|
+
const isSqlPosition = handleAdmits || cand.isQueryBuilderShape;
|
|
749
|
+
const isSqlQuery = sqlOk !== null || isSqlPosition || isTaggedSqlCall;
|
|
750
|
+
if (!isSqlQuery && !isOrmCall)
|
|
751
|
+
return null;
|
|
752
|
+
const sqlAstNode = sqlOk ? sqlOk.ast : null;
|
|
753
|
+
const builderVerb = sqlAstNode ? null : cand.builderVerb;
|
|
754
|
+
const sqlTables = sqlAstNode ? extractTableNames(sqlAstNode) : [];
|
|
755
|
+
const ormTables = isOrmCall ? cand.ormTables : [];
|
|
756
|
+
const tables = [...new Set([...sqlTables, ...ormTables])];
|
|
757
|
+
const facts = sqlAstNode ? whereFacts(sqlAstNode) : null;
|
|
758
|
+
const hasFilter = (facts
|
|
759
|
+
? (facts.hasWhere && !facts.whereIsTautology) || facts.hasHaving || facts.hasLimit
|
|
760
|
+
: false) ||
|
|
761
|
+
(isOrmCall && cand.ormHasFilter);
|
|
762
|
+
// Security: static arms 1–3 ran raw-side; arm 4 (a learned DB wrapper carrying
|
|
763
|
+
// bind params) is the one cross-file dependency, corrected here.
|
|
764
|
+
let security = {
|
|
765
|
+
parameterized: cand.staticParameterized,
|
|
766
|
+
injectionRisk: cand.staticInjectionRisk,
|
|
767
|
+
escaped: cand.staticEscaped,
|
|
768
|
+
};
|
|
769
|
+
if (cand.arm4CalleeName && learnedWrappers.has(cand.arm4CalleeName)) {
|
|
770
|
+
security = { parameterized: true, injectionRisk: false, escaped: false };
|
|
771
|
+
}
|
|
772
|
+
const injectionRisk = security.injectionRisk && verdict?.kind === 'handle';
|
|
773
|
+
return {
|
|
774
|
+
type: classifyCallType(isSqlQuery, isOrmCall),
|
|
775
|
+
method: cand.method,
|
|
776
|
+
file: cand.file,
|
|
777
|
+
line: cand.line,
|
|
778
|
+
column: cand.column,
|
|
779
|
+
tables,
|
|
780
|
+
queryText: cand.nodeText,
|
|
781
|
+
hasOrganizationFilter: cand.hasOrganizationFilter,
|
|
782
|
+
hasFilter,
|
|
783
|
+
isWrite: sqlAstNode ? isWriteStatement(sqlAstNode) : builderVerb !== null,
|
|
784
|
+
isMassWrite: sqlAstNode ? isMassWriteStatement(sqlAstNode) : builderVerb === 'update',
|
|
785
|
+
isUpsert: sqlAstNode
|
|
786
|
+
? isUpsertStatement(sqlAstNode) || sqlOk?.conflictClauseTruncated === true
|
|
787
|
+
: false,
|
|
788
|
+
isRawInsert: sqlAstNode ? (sqlAstNode.type === 'insert' || sqlAstNode.type === 'replace') : false,
|
|
789
|
+
insertColumns: sqlAstNode ? rawInsertColumnsFromAst(sqlAstNode) : null,
|
|
790
|
+
sqlWhereColumns: sqlAstNode ? [...whereColumnRefs(sqlAstNode)] : null,
|
|
791
|
+
hasParameterizedQuery: security.parameterized,
|
|
792
|
+
hasSqlInjectionRisk: injectionRisk,
|
|
793
|
+
sqlEscaped: security.escaped,
|
|
794
|
+
enclosingFunction: cand.enclosingFunction,
|
|
795
|
+
resolvedWhere: cand.resolvedWhere ?? undefined,
|
|
796
|
+
handleVerdict: verdict ?? undefined,
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* The corpus `data-access-calls` producer: re-derive each file's `dbProvenanced`
|
|
801
|
+
* (TS via `classifyBuildProvenance`; Go via the fixed-point seed) from the raw
|
|
802
|
+
* `data-access-calls-candidates` fact + the provenance fixed point, then re-fold
|
|
803
|
+
* the legacy `extractDatabaseCalls` pipeline — discovery filter (`isDbCallCandidate`)
|
|
804
|
+
* → line dedup (template preferred, else first in pre-order) → `buildDatabaseCall`
|
|
805
|
+
* — with no AST. The dedup runs on the *discovered* set, not the built set, so a
|
|
806
|
+
* discovered-but-rejected node still shadows an admitted node on the same line
|
|
807
|
+
* exactly as the legacy pass did.
|
|
808
|
+
*
|
|
809
|
+
* @param candidates the raw `data-access-calls-candidates` facts (one per file)
|
|
810
|
+
* @param resolution the per-corpus resolution inputs (facts + dialect/project tail)
|
|
811
|
+
* @returns the resolved DB calls, deduped and rebuilt with no AST
|
|
812
|
+
*/
|
|
813
|
+
export function classifyDataAccessCalls(candidates, resolution) {
|
|
814
|
+
const { withinFacts, provenance, activityFacts, sqlDialect, declaredTypePackages, projectRoot, tsconfig, verdictCache } = resolution;
|
|
815
|
+
const tsExtracts = rehydrateWithinTsExtracts(withinFacts);
|
|
816
|
+
const goExtracts = rehydrateWithinGoExtracts(withinFacts);
|
|
817
|
+
const seeds = rehydrateReceiverProvenance(provenance);
|
|
818
|
+
const activityByFile = new Map(activityFacts.map((f) => [f.file, f]));
|
|
819
|
+
const resolver = makeSpecifierResolver(withinFacts, projectRoot, tsconfig);
|
|
820
|
+
const heritageResolver = makeHeritageResolver(projectRoot, declaredTypePackages) ?? undefined;
|
|
821
|
+
// Group candidates by file, preserving the raw fact's (input-file) order.
|
|
822
|
+
const byFile = new Map();
|
|
823
|
+
for (const cand of candidates) {
|
|
824
|
+
let list = byFile.get(cand.file);
|
|
825
|
+
if (!list) {
|
|
826
|
+
list = [];
|
|
827
|
+
byFile.set(cand.file, list);
|
|
828
|
+
}
|
|
829
|
+
list.push(cand);
|
|
830
|
+
}
|
|
831
|
+
const out = [];
|
|
832
|
+
for (const [file, fileCands] of byFile) {
|
|
833
|
+
const isGo = fileCands[0].format === 'go';
|
|
834
|
+
const { dbProvenanced, bindings, bindingsByScope, goEnv, interfaceFields } = foldReceiverEnvironment({
|
|
835
|
+
file, isGo, tsExtracts, goExtracts, seeds, activityByFile, sqlDialect,
|
|
836
|
+
});
|
|
837
|
+
const learnedWrappers = new Set([...dbProvenanced.values()].filter((ev) => ev.reason === 'wrapper').map((ev) => ev.identifier));
|
|
838
|
+
const resolveImport = resolver ? (source) => resolver(source, file) : undefined;
|
|
839
|
+
const env = fileReceiverEnv({ dbProvenanced, bindings, bindingsByScope, goEnv, interfaceFields }, { sqlDialect, declaredTypePackages, resolveImport, resolveHeritageField: heritageResolver });
|
|
840
|
+
// 1. Discovery filter — `isDbCallCandidate`, re-folding the handle verdict.
|
|
841
|
+
const discovered = [];
|
|
842
|
+
for (const cand of fileCands) {
|
|
843
|
+
const verdict = reFoldHandleVerdict(dataAccessIdentity(cand), env, file, verdictCache);
|
|
844
|
+
const handleAdmits = verdict !== null && verdict.kind !== 'not-handle';
|
|
845
|
+
const isCandidate = handleAdmits || cand.isQueryBuilderShape || cand.isTaggedSqlCall || cand.isVariableAssignmentSql;
|
|
846
|
+
if (isCandidate)
|
|
847
|
+
discovered.push({ cand, verdict });
|
|
848
|
+
}
|
|
849
|
+
// 2. Line dedup — `dedupeCandidateNodes` (template preferred, else first).
|
|
850
|
+
const byLine = new Map();
|
|
851
|
+
for (const d of discovered) {
|
|
852
|
+
const line = d.cand.line;
|
|
853
|
+
if (!byLine.has(line))
|
|
854
|
+
byLine.set(line, []);
|
|
855
|
+
byLine.get(line).push(d);
|
|
856
|
+
}
|
|
857
|
+
const unique = [];
|
|
858
|
+
for (const items of byLine.values()) {
|
|
859
|
+
if (items.length === 1) {
|
|
860
|
+
unique.push(items[0]);
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
unique.push(items.find((it) => it.cand.isTemplateLiteral) ?? items[0]);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
// 3. Build — `buildDatabaseCall` over the deduped set.
|
|
867
|
+
for (const { cand, verdict } of unique) {
|
|
868
|
+
const built = buildDataAccessCall(cand, verdict, dbProvenanced, sqlDialect, learnedWrappers);
|
|
869
|
+
if (built)
|
|
870
|
+
out.push(built);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
return out;
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* The corpus `loop-queries` producer: re-derive each file's `dbProvenanced` (TS
|
|
877
|
+
* via `classifyBuildProvenance`), re-fold the strict-handle filter
|
|
878
|
+
* (`isDbCallNode`'s `identifyHandle`), dedup by loop byte-offset (one finding per
|
|
879
|
+
* loop, first wins), and assign the stable symbol. The provenance-free
|
|
880
|
+
* discriminators already ran in the raw producer; only the three
|
|
881
|
+
* provenance-dependent steps remain.
|
|
882
|
+
*
|
|
883
|
+
* @param candidates the raw `loop-query-candidates` facts (one per file)
|
|
884
|
+
* @param resolution the per-corpus resolution inputs (facts + dialect/project tail)
|
|
885
|
+
* @returns the resolved loop-query facts (deduped, stable symbols assigned)
|
|
886
|
+
*/
|
|
887
|
+
export function classifyLoopQueries(candidates, resolution) {
|
|
888
|
+
const { withinFacts, provenance, activityFacts, sqlDialect, declaredTypePackages, projectRoot, tsconfig, verdictCache } = resolution;
|
|
889
|
+
const tsExtracts = rehydrateWithinTsExtracts(withinFacts);
|
|
890
|
+
const seeds = rehydrateReceiverProvenance(provenance);
|
|
891
|
+
const activityByFile = new Map(activityFacts.map((f) => [f.file, f]));
|
|
892
|
+
const resolver = makeSpecifierResolver(withinFacts, projectRoot, tsconfig);
|
|
893
|
+
const heritageResolver = makeHeritageResolver(projectRoot, declaredTypePackages) ?? undefined;
|
|
894
|
+
const byFile = new Map();
|
|
895
|
+
for (const cand of candidates) {
|
|
896
|
+
let list = byFile.get(cand.file);
|
|
897
|
+
if (!list) {
|
|
898
|
+
list = [];
|
|
899
|
+
byFile.set(cand.file, list);
|
|
900
|
+
}
|
|
901
|
+
list.push(cand);
|
|
902
|
+
}
|
|
903
|
+
const out = [];
|
|
904
|
+
for (const [file, fileCands] of byFile) {
|
|
905
|
+
const extract = tsExtracts.get(file);
|
|
906
|
+
const activity = rehydrateReceiverActivity(activityByFile.get(file));
|
|
907
|
+
const dbProvenanced = extract
|
|
908
|
+
? classifyBuildProvenance(extract, seeds.get(file) ?? new Map(), activity.bindings, activity.r3Sites, sqlDialect)
|
|
909
|
+
: new Map();
|
|
910
|
+
const reported = new Set();
|
|
911
|
+
const loopOrdinals = new Map();
|
|
912
|
+
const resolveImport = resolver ? (source) => resolver(source, file) : undefined;
|
|
913
|
+
const env = fileReceiverEnv({ dbProvenanced, bindings: activity.bindings, bindingsByScope: activity.bindingsByScope, goEnv: undefined, interfaceFields: extract?.interfaceFields }, { sqlDialect, declaredTypePackages, resolveImport, resolveHeritageField: heritageResolver });
|
|
914
|
+
for (const cand of fileCands) {
|
|
915
|
+
const verdict = reFoldHandleVerdict(loopQueryIdentity(cand), env, file, verdictCache);
|
|
916
|
+
if (!verdict || verdict.kind !== 'handle')
|
|
917
|
+
continue;
|
|
918
|
+
const dedupKey = String(cand.loopStartOffset);
|
|
919
|
+
if (reported.has(dedupKey))
|
|
920
|
+
continue;
|
|
921
|
+
reported.add(dedupKey);
|
|
922
|
+
const symbol = nextSymbol(cand.enclosingFunction, 'loop-query', loopOrdinals);
|
|
923
|
+
out.push({
|
|
924
|
+
file: cand.file,
|
|
925
|
+
line: cand.line,
|
|
926
|
+
column: cand.column,
|
|
927
|
+
symbol,
|
|
928
|
+
loopLine: cand.loopLine,
|
|
929
|
+
depth: cand.depth,
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
return out;
|
|
934
|
+
}
|
|
935
|
+
// ── `unproven-query-receivers` reduction (Spec 70 2c) ────────────────────────
|
|
936
|
+
/**
|
|
937
|
+
* The corpus `unproven-query-receivers` reduction (Spec 70 2c) — the fifth
|
|
938
|
+
* receiver consumer, re-derived from the raw `data-access-calls-candidates` fact
|
|
939
|
+
* + the provenance fixed point with no AST. It re-folds `identifyHandle` per
|
|
940
|
+
* member candidate and emits an `UnprovenQueryReceiver` when the verdict is
|
|
941
|
+
* `unproven` and the call is query-shaped — mirroring the pre-pass's candidacy
|
|
942
|
+
* filter (language-independent string-arg, the SQL literal as admission proof)
|
|
943
|
+
* and its `root === null` skip (re-folded
|
|
944
|
+
* via `reFoldHandleVerdict`'s null on a missing root). This is the source for the
|
|
945
|
+
* `cannot-fire` coverage diagnostic, re-homed from `collectCannotFireDiagnostics`
|
|
946
|
+
* (which read the pre-pass's `unprovenQueryReceivers`).
|
|
947
|
+
*
|
|
948
|
+
* @param candidates the raw `data-access-calls-candidates` facts (one per file)
|
|
949
|
+
* @param resolution the per-corpus resolution inputs (facts + dialect/project tail)
|
|
950
|
+
* @returns the unproven query-receiver records, deduped and rebuilt
|
|
951
|
+
*/
|
|
952
|
+
export function classifyUnprovenQueryReceivers(candidates, resolution) {
|
|
953
|
+
const { withinFacts, provenance, activityFacts, sqlDialect, declaredTypePackages, projectRoot, tsconfig, verdictCache } = resolution;
|
|
954
|
+
const tsExtracts = rehydrateWithinTsExtracts(withinFacts);
|
|
955
|
+
const goExtracts = rehydrateWithinGoExtracts(withinFacts);
|
|
956
|
+
const seeds = rehydrateReceiverProvenance(provenance);
|
|
957
|
+
const activityByFile = new Map(activityFacts.map((f) => [f.file, f]));
|
|
958
|
+
const resolver = makeSpecifierResolver(withinFacts, projectRoot, tsconfig);
|
|
959
|
+
const heritageResolver = makeHeritageResolver(projectRoot, declaredTypePackages) ?? undefined;
|
|
960
|
+
const byFile = new Map();
|
|
961
|
+
for (const cand of candidates) {
|
|
962
|
+
let list = byFile.get(cand.file);
|
|
963
|
+
if (!list) {
|
|
964
|
+
list = [];
|
|
965
|
+
byFile.set(cand.file, list);
|
|
966
|
+
}
|
|
967
|
+
list.push(cand);
|
|
968
|
+
}
|
|
969
|
+
const out = [];
|
|
970
|
+
for (const [file, fileCands] of byFile) {
|
|
971
|
+
const isGo = fileCands[0].format === 'go';
|
|
972
|
+
const { dbProvenanced, bindings, bindingsByScope, goEnv, interfaceFields } = foldReceiverEnvironment({
|
|
973
|
+
file, isGo, tsExtracts, goExtracts, seeds, activityByFile, sqlDialect,
|
|
974
|
+
});
|
|
975
|
+
// Re-fold each member candidate to its unproven verdict, then line-dedup —
|
|
976
|
+
// mirroring `classifyDataAccessCalls`'s step 2 (template preferred, else
|
|
977
|
+
// first). The broadened discovery matches both the `call_expression` node and
|
|
978
|
+
// its `template_string` child, so without the dedup one query-shaped site
|
|
979
|
+
// emits two identical cannot-fire diagnostics and doubles the coverage count.
|
|
980
|
+
const resolveImport = resolver ? (source) => resolver(source, file) : undefined;
|
|
981
|
+
const env = fileReceiverEnv({ dbProvenanced, bindings, bindingsByScope, goEnv, interfaceFields }, { sqlDialect, declaredTypePackages, resolveImport, resolveHeritageField: heritageResolver });
|
|
982
|
+
const admitted = [];
|
|
983
|
+
for (const cand of fileCands) {
|
|
984
|
+
const id = dataAccessIdentity(cand);
|
|
985
|
+
// Candidacy filter only — mirror the pre-pass's member-callee gate (an
|
|
986
|
+
// identifier callee is not a query-shaped *call site*). A member call is
|
|
987
|
+
// admitted as unproven only when it carries a static SQL argument (the
|
|
988
|
+
// sql-argument evidence source, `handleSqlArg`) or is genuinely query-shaped
|
|
989
|
+
// (the real `isQueryBuilderShape` test, carried on the candidate) — a site
|
|
990
|
+
// with neither evidence source is not a data-access site and nothing is
|
|
991
|
+
// reported about it. `reFoldHandleVerdict` → `identifyHandle` re-folds the
|
|
992
|
+
// same discriminant over the re-derived provenance, so a null-arg
|
|
993
|
+
// `not-handle` root resolves to `not-handle` below.
|
|
994
|
+
if (id.calleeType !== 'member')
|
|
995
|
+
continue;
|
|
996
|
+
if (cand.handleSqlArg === null && !cand.isQueryBuilderShape)
|
|
997
|
+
continue;
|
|
998
|
+
const verdict = reFoldHandleVerdict(id, env, file, verdictCache);
|
|
999
|
+
if (!verdict || verdict.kind !== 'unproven')
|
|
1000
|
+
continue;
|
|
1001
|
+
admitted.push({ cand, verdict });
|
|
1002
|
+
}
|
|
1003
|
+
const byLine = new Map();
|
|
1004
|
+
for (const a of admitted) {
|
|
1005
|
+
const line = a.cand.line;
|
|
1006
|
+
if (!byLine.has(line))
|
|
1007
|
+
byLine.set(line, []);
|
|
1008
|
+
byLine.get(line).push(a);
|
|
1009
|
+
}
|
|
1010
|
+
const unique = [];
|
|
1011
|
+
for (const items of byLine.values()) {
|
|
1012
|
+
unique.push(items.length === 1 ? items[0] : (items.find((it) => it.cand.isTemplateLiteral) ?? items[0]));
|
|
1013
|
+
}
|
|
1014
|
+
for (const { cand, verdict } of unique) {
|
|
1015
|
+
const id = dataAccessIdentity(cand);
|
|
1016
|
+
const receiver = id.receiver ?? id.root ?? '(unknown)';
|
|
1017
|
+
const root = id.root ?? receiver;
|
|
1018
|
+
const method = id.method ?? '';
|
|
1019
|
+
const reason = describeUnprovenReceiver(receiver, method, root, verdict.reason, cand.isQueryBuilderShape, isGo ? 'go' : 'typescript');
|
|
1020
|
+
out.push({ file, line: cand.line, receiver, root, method, reason });
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
return out;
|
|
1024
|
+
}
|
|
1025
|
+
//# sourceMappingURL=receiverConsumers.js.map
|