rea-agents 6.2.0 → 6.4.0
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/README.md +24 -23
- package/bridge/ghidra/ReaGhidraApplySeeds.java +151 -0
- package/bridge/ghidra/ReaGhidraBridge.java +597 -209
- package/bridge/ghidra/ReaGhidraNoReturnFix.java +123 -0
- package/bridge/hopper_bridge.py +2 -0
- package/dist/adb/AdbConfiguration.js +88 -0
- package/dist/adb/AdbDeviceOutput.js +186 -0
- package/dist/adb/AdbProvider.js +1190 -0
- package/dist/adb/AdbShellOutput.js +309 -0
- package/dist/android/AndroidTargetSnapshot.js +104 -22
- package/dist/android/JadxConfiguration.js +44 -24
- package/dist/android/JadxProvider.js +59 -21
- package/dist/android/JadxSession.js +51 -9
- package/dist/apktool/ApktoolConfiguration.js +84 -0
- package/dist/apktool/ApktoolDecodeOutput.js +59 -0
- package/dist/apktool/ApktoolProvider.js +506 -0
- package/dist/application/AnalysisProvider.js +8 -2
- package/dist/application/AppBundleExecutable.js +27 -22
- package/dist/application/BinaryTargetResolver.js +85 -19
- package/dist/application/BrowserScenarioEvidence.js +2 -2
- package/dist/application/CapabilityInventory.js +11 -1
- package/dist/application/ClientConfigurationDocument.js +98 -0
- package/dist/application/ClientConfigurationFiles.js +91 -0
- package/dist/application/ClientRegistrationEnvironment.js +35 -0
- package/dist/application/ClientRegistrationStatus.js +75 -27
- package/dist/application/DirectAnalysis.js +14 -8
- package/dist/application/DirectAnalysisCleanup.js +1 -2
- package/dist/application/DirectAnalysisStatus.js +3 -6
- package/dist/application/Doctor.js +27 -34
- package/dist/application/DoctorDiagnostics.js +1 -1
- package/dist/application/EvidenceBundleCommands.js +6 -12
- package/dist/application/EvidenceBundleFiles.js +1 -1
- package/dist/application/GeminiClientSettings.js +139 -0
- package/dist/application/HermesClientHome.js +115 -0
- package/dist/application/HopperDownload.js +39 -0
- package/dist/application/InvestigationProviders.js +10 -4
- package/dist/application/JsonFiles.js +16 -15
- package/dist/application/JsonInputFile.js +252 -0
- package/dist/application/LinuxHopper.js +6 -13
- package/dist/application/MacHopper.js +172 -149
- package/dist/application/MipsElfAbiFlags.js +140 -0
- package/dist/application/ProviderOperationExecution.js +31 -0
- package/dist/application/ReconstructionObligationCandidates.js +16 -3
- package/dist/application/ReconstructionObligationLedgerProjection.js +3 -1
- package/dist/application/ReferenceSourceImport.js +76 -29
- package/dist/application/ReferenceSourceImportEntries.js +18 -9
- package/dist/application/ReferenceSourceImportPolicy.js +99 -23
- package/dist/application/ReferenceSourceImportTypes.js +30 -22
- package/dist/application/ReferenceSourceVcsAdapter.js +145 -30
- package/dist/application/RegularFileRead.js +103 -0
- package/dist/application/Setup.js +69 -10
- package/dist/application/SetupClientConfiguration.js +134 -23
- package/dist/application/SetupHost.js +102 -22
- package/dist/application/SetupPlan.js +18 -17
- package/dist/application/SetupSkill.js +81 -13
- package/dist/application/SupportedClients.js +305 -37
- package/dist/application/Uninstall.js +172 -8
- package/dist/application/UpdateMaintenance.js +23 -23
- package/dist/application/Utf8JsonInput.js +71 -0
- package/dist/application/WebScriptExportService.js +130 -57
- package/dist/application/WebSourceLocationService.js +3 -0
- package/dist/application/adb/AdbDeviceAnalysisPort.js +1 -0
- package/dist/application/adb/AdbDeviceAnalysisService.js +13 -0
- package/dist/application/analysisView/AnalysisViewService.js +40 -2
- package/dist/application/android/AndroidAnalysisService.js +1 -1
- package/dist/application/apktool/ApktoolResourceAnalysisPort.js +1 -0
- package/dist/application/apktool/ApktoolResourceAnalysisService.js +13 -0
- package/dist/application/binary/AnalysisClientCleanup.js +0 -24
- package/dist/application/binary/AnalysisSnapshotCache.js +5 -4
- package/dist/application/binary/BinarySession.js +18 -1
- package/dist/application/binary/BinarySessionOpen.js +9 -1
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +2 -1
- package/dist/application/binaryDiagnostics/PeResourcesPort.js +1 -0
- package/dist/application/binaryDiagnostics/PeResourcesService.js +111 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +2 -1
- package/dist/application/evm/EvmInterfaceService.js +3 -0
- package/dist/application/firmware/FirmwareAnalysisService.js +3 -0
- package/dist/application/investigation/InspectEvidenceBundle.js +18 -0
- package/dist/application/javascript/ElectronActiveEvidence.js +2 -2
- package/dist/application/javascript/ElectronBoundaryAnalysis.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphContext.js +3 -2
- package/dist/application/javascript/ElectronBoundaryGraphIpc.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphNative.js +20 -3
- package/dist/application/javascript/ElectronBoundaryGraphWindows.js +3 -3
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +1 -0
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +107 -46
- package/dist/application/javascript/JavaScriptApplicationService.js +23 -11
- package/dist/application/javascript/JavaScriptApplicationWorkflowEvidence.js +5 -6
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +59 -45
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +171 -36
- package/dist/application/javascript/JavaScriptArtifactGraphAccumulator.js +14 -16
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +74 -36
- package/dist/application/javascript/JavaScriptArtifactGraphBundlers.js +4 -3
- package/dist/application/javascript/JavaScriptArtifactGraphContext.js +11 -5
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +53 -42
- package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +92 -10
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +293 -238
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +120 -28
- package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +4 -0
- package/dist/application/javascript/JavaScriptJsonModules.js +2 -2
- package/dist/application/javascript/JavaScriptModuleRelationships.js +10 -20
- package/dist/application/javascript/JavaScriptRecoveryService.js +3 -0
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +11 -27
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +11 -5
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +206 -66
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +18 -23
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +5 -2
- package/dist/application/javascript/JavaScriptSemanticGraphEvidence.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphFingerprintProjection.js +2 -2
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +7 -5
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +6 -4
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +4 -4
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +29 -15
- package/dist/application/javascript/JavaScriptSemanticTraceService.js +15 -10
- package/dist/application/jeb/JebAnalysisPort.js +1 -0
- package/dist/application/jeb/JebAnalysisService.js +13 -0
- package/dist/application/managed/ManagedApplicationGraphService.js +1 -1
- package/dist/application/native/NativeCallRoutes.js +2 -4
- package/dist/application/native/NativeUiActionTrace.js +16 -8
- package/dist/application/native/NativeValueTrace.js +23 -6
- package/dist/application/process/ProcessCli.js +25 -20
- package/dist/artifacts/ArtifactPaths.js +129 -8
- package/dist/artifacts/ArtifactProvider.js +34 -31
- package/dist/artifacts/ArtifactProviderMetadata.js +1 -4
- package/dist/artifacts/ArtifactReader.js +23 -0
- package/dist/artifacts/ArtifactResourceScope.js +100 -0
- package/dist/artifacts/AsarArtifactReader.js +218 -80
- package/dist/artifacts/AsarHeader.js +24 -0
- package/dist/artifacts/DirectoryArtifactReader.js +168 -65
- package/dist/artifacts/MachOSliceArtifactReader.js +116 -39
- package/dist/artifacts/NativeDmgArtifactReader.js +179 -87
- package/dist/artifacts/NativeDmgOwnership.js +109 -0
- package/dist/artifacts/SafeOutputTree.js +245 -70
- package/dist/artifacts/SafeOutputTreeCleanup.js +45 -0
- package/dist/artifacts/SafeOutputTreeCreationFailure.js +20 -0
- package/dist/artifacts/SafeOutputTreeIdentity.js +42 -0
- package/dist/artifacts/SafeOutputTreeReadback.js +33 -0
- package/dist/artifacts/ZipArtifactReader.js +77 -27
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +58 -18
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +62 -24
- package/dist/artifacts/apple/KeyedArchiveReader.js +76 -49
- package/dist/artifacts/apple/MachoLoadCommandReader.js +36 -6
- package/dist/artifacts/extraction/ArtifactExtraction.js +134 -92
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +116 -50
- package/dist/artifacts/inventory/ArtifactInventory.js +5 -4
- package/dist/artifacts/inventory/classify.js +87 -25
- package/dist/artifacts/inventory/hashStableRootArtifact.js +70 -0
- package/dist/artifacts/inventory/reader.js +13 -5
- package/dist/artifacts/inventory/scanCanonical.js +73 -30
- package/dist/artifacts/inventory/scanReader.js +43 -20
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +72 -28
- package/dist/artifacts/javascript/JavaScriptSourceAnalysis.js +3 -0
- package/dist/browser/BrowserScenarioPartialObservation.js +8 -2
- package/dist/browser/BrowserScenarioSecrets.js +52 -37
- package/dist/browser/CdpBrowserProvider.js +9 -3
- package/dist/browser/CdpCaptureDocuments.js +40 -6
- package/dist/browser/CdpCaptureDomSvg.js +210 -0
- package/dist/browser/CdpCaptureEventBodyShapes.js +4 -8
- package/dist/browser/CdpCaptureEventHandlers.js +26 -9
- package/dist/browser/CdpCaptureEvents.js +4 -9
- package/dist/browser/CdpCaptureStorageFingerprints.js +3 -3
- package/dist/browser/CdpConnection.js +22 -5
- package/dist/browser/CdpElectronInspection.js +2 -2
- package/dist/browser/CdpElectronProvider.js +4 -3
- package/dist/browser/CdpElectronScripts.js +2 -2
- package/dist/browser/CdpPageCapture.js +1 -1
- package/dist/browser/CdpTargetSession.js +30 -34
- package/dist/browser/CdpWebMcpDiscovery.js +48 -23
- package/dist/browser/ElectronFileScope.js +99 -9
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +63 -7
- package/dist/browser/PlaywrightElectronActiveProvider.js +11 -6
- package/dist/browser/PlaywrightScenarioArtifacts.js +5 -5
- package/dist/browser/PlaywrightScenarioBrowser.js +208 -43
- package/dist/browser/PlaywrightScenarioSession.js +130 -65
- package/dist/browser/PlaywrightScenarioStorage.js +507 -0
- package/dist/browser/PngVisualDiff.js +198 -29
- package/dist/browser/WebSourceMapFetcher.js +35 -9
- package/dist/browser/assets/LocalWebScriptArtifacts.js +3 -1
- package/dist/browser/assets/PublishWebScripts.js +75 -20
- package/dist/browser/assets/ScenarioScriptCapture.js +8 -12
- package/dist/browser/assets/WebArtifactReads.js +23 -1
- package/dist/browser/assets/WebSourceLocationArtifacts.js +1 -0
- package/dist/browser/execution/CdpExecutionCapture.js +3 -3
- package/dist/browser/execution/CdpPreciseCoverage.js +5 -8
- package/dist/browser/history/HarCapture.js +14 -0
- package/dist/browser/history/HarCaptureProcess.js +2 -10
- package/dist/browser/history/MitmproxyCaptureAdapter.js +3 -1
- package/dist/browser/modules/WebModuleArtifacts.js +1 -0
- package/dist/cli/adbCommands.js +337 -0
- package/dist/cli/analysisViewCommands.js +39 -1
- package/dist/cli/apktoolCommands.js +53 -0
- package/dist/cli/artifactCommands.js +8 -11
- package/dist/cli/binaryDiagnosticsCommands.js +19 -1
- package/dist/cli/browserAdvancedCommands.js +65 -36
- package/dist/cli/coreAnalysisCommands.js +2 -2
- package/dist/cli/coreBinaryCommands.js +12 -13
- package/dist/cli/coreNativeCommands.js +1 -14
- package/dist/cli/electronCommands.js +14 -10
- package/dist/cli/evmCommands.js +13 -4
- package/dist/cli/firmwareCommands.js +7 -2
- package/dist/cli/javascriptApplicationAnalysis.js +19 -13
- package/dist/cli/javascriptRecoveryCommands.js +22 -15
- package/dist/cli/jebCommands.js +99 -0
- package/dist/cli/jsonOutput.js +12 -4
- package/dist/cli/referenceSourceImportStatus.js +7 -0
- package/dist/cli/setupCommands.js +15 -3
- package/dist/cli/streamedJsonOutput.js +83 -4
- package/dist/cli/utilityCommands.js +68 -22
- package/dist/cli/webScriptCommands.js +20 -1
- package/dist/cli/webSourceLocationCommands.js +21 -9
- package/dist/cli.js +11 -2
- package/dist/cliBrowserScenarioCommands.js +2 -1
- package/dist/cliCommandNames.js +32 -0
- package/dist/cliJsonInput.js +47 -34
- package/dist/cliObservationOptions.js +7 -0
- package/dist/composition/adb.js +3 -0
- package/dist/composition/apktool.js +3 -0
- package/dist/composition/auxiliaryAnalysisProviders.js +5 -4
- package/dist/composition/binaryDiagnostics.js +4 -0
- package/dist/composition/browserScenario.js +2 -2
- package/dist/composition/directAnalysis.js +14 -7
- package/dist/composition/javascriptAnalysisWorkerProcess.js +48 -0
- package/dist/composition/jeb.js +6 -0
- package/dist/config/environment.js +10 -0
- package/dist/config/ghidraLanguageOverride.js +9 -0
- package/dist/config/mcpInputSchemaProfile.js +27 -0
- package/dist/config/parseConfig.js +28 -1
- package/dist/contracts/adb/adbToolContracts.js +353 -0
- package/dist/contracts/advertisedInputExamples.js +48 -0
- package/dist/contracts/analysisDetail.js +10 -0
- package/dist/contracts/analysisViewToolContracts.js +17 -2
- package/dist/contracts/apktool/apktoolToolContracts.js +33 -0
- package/dist/contracts/artifactComparisonExample.js +5 -5
- package/dist/contracts/artifactToolContracts.js +8 -5
- package/dist/contracts/browserToolContracts.js +1 -1
- package/dist/contracts/compactInputSchema.js +256 -0
- package/dist/contracts/errorSchemas.js +3 -1
- package/dist/contracts/functionComparisonExample.js +8 -0
- package/dist/contracts/functionWorkflowToolContracts.js +1 -1
- package/dist/contracts/inputSchemaPresentation.js +104 -13
- package/dist/contracts/javascript/electronToolContracts.js +16 -3
- package/dist/contracts/javascript/javascriptApplicationWorkflowExamples.js +3 -2
- package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +6 -3
- package/dist/contracts/javascript/javascriptRecoveryToolContracts.js +1 -1
- package/dist/contracts/javascript/javascriptRuntimeReconciliationExample.js +8 -7
- package/dist/contracts/jeb/jebToolContracts.js +64 -0
- package/dist/contracts/managed/managedToolContracts.js +3 -2
- package/dist/contracts/mobileApplicationGraphExamples.js +5 -5
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +25 -3
- package/dist/contracts/native/nativeToolContracts.js +1 -1
- package/dist/contracts/officialToolContracts.js +5 -5
- package/dist/contracts/sessionLifecycleInputs.js +4 -3
- package/dist/contracts/sessionStatusContract.js +3 -2
- package/dist/contracts/sessionToolContracts.js +5 -4
- package/dist/contracts/sessionToolSchemas.js +9 -4
- package/dist/contracts/toolContractExamples.js +6 -0
- package/dist/contracts/toolContractTypes.js +3 -0
- package/dist/contracts/toolContracts.js +6 -0
- package/dist/contracts/toolEffects.js +167 -0
- package/dist/contracts/toolOutputSchemaGroups.js +7 -5
- package/dist/contracts/toolOutputSchemaPrimitives.js +2 -5
- package/dist/contracts/toolSchemaMetadata.js +82 -7
- package/dist/domain/adb/adbDeviceAnalysis.js +583 -0
- package/dist/domain/analysisErrorBase.js +5 -0
- package/dist/domain/analysisErrorCleanup.js +29 -0
- package/dist/domain/analysisErrorPresentation.js +18 -4
- package/dist/domain/analysisErrorProjection.js +4 -1
- package/dist/domain/analysisSnapshot.js +5 -2
- package/dist/domain/analysisView/analysisView.js +53 -5
- package/dist/domain/analysisView/binaryLayoutView.js +2 -0
- package/dist/domain/analysisView/javascriptApplicationView.js +2 -0
- package/dist/domain/analysisView/nativeFunctionView.js +155 -0
- package/dist/domain/android/androidApplication.js +25 -20
- package/dist/domain/android/androidPartialObservation.js +36 -0
- package/dist/domain/apktool/apktoolResourceAnalysis.js +77 -0
- package/dist/domain/apple/appleApplication.js +40 -23
- package/dist/domain/apple/appleBundleAnatomy.js +95 -28
- package/dist/domain/apple/dyldPaths.js +9 -1
- package/dist/domain/apple/dylibResolution.js +3 -3
- package/dist/domain/apple/interfaceBuilderGraph.js +22 -19
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +10 -1
- package/dist/domain/artifactComparison.js +39 -11
- package/dist/domain/artifactGraph.js +6 -4
- package/dist/domain/artifactIdentity.js +37 -9
- package/dist/domain/artifactInspection.js +10 -50
- package/dist/domain/artifactIntegrityPolicy.js +10 -0
- package/dist/domain/artifactInventoryEvidence.js +16 -17
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/binaryTarget.js +16 -0
- package/dist/domain/binaryTargetTypes.js +8 -1
- package/dist/domain/browserCompleteness.js +3 -2
- package/dist/domain/browserObservationSchemas.js +8 -4
- package/dist/domain/browserScenarioCaptureValues.js +2 -2
- package/dist/domain/browserScenarioNormalization.js +3 -3
- package/dist/domain/browserScenarioValues.js +3 -2
- package/dist/domain/callPath.js +8 -10
- package/dist/domain/canonicalDigest.js +7 -1
- package/dist/domain/canonicalJsonDigestSteps.js +34 -12
- package/dist/domain/canonicalOrdering.js +1 -13
- package/dist/domain/changedBehavior.js +2 -3
- package/dist/domain/compactStringIdentity.js +9 -0
- package/dist/domain/comparisonSemantics.js +0 -5
- package/dist/domain/digests.js +0 -3
- package/dist/domain/evidence.js +12 -6
- package/dist/domain/evidenceBundle.js +51 -33
- package/dist/domain/evidenceRecordSummary.js +144 -0
- package/dist/domain/firmware/firmwareAnalysis.js +4 -3
- package/dist/domain/functionComparison.js +2 -1
- package/dist/domain/functionComparisonNormalization.js +4 -3
- package/dist/domain/functionComparisonResults.js +2 -2
- package/dist/domain/functionDossierEvidence.js +2 -1
- package/dist/domain/hopperValues.js +11 -15
- package/dist/domain/inputIssueProjection.js +16 -1
- package/dist/domain/javascript/electronActiveObservation.js +4 -3
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +14 -15
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +20 -21
- package/dist/domain/javascript/electronStaticAnalysisNative.js +73 -41
- package/dist/domain/javascript/electronStaticAnalysisValues.js +24 -4
- package/dist/domain/javascript/javascriptAnalysisResourceControls.js +45 -0
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +6 -1
- package/dist/domain/javascript/javascriptApplicationChangeGraph.js +18 -14
- package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +4 -0
- package/dist/domain/javascript/javascriptApplicationGraph.js +91 -28
- package/dist/domain/javascript/javascriptApplicationProjectionResources.js +35 -0
- package/dist/domain/javascript/javascriptApplicationVersionComparison.js +4 -4
- package/dist/domain/javascript/javascriptApplicationVersionComparisonSchemas.js +37 -22
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +72 -45
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +16 -8
- package/dist/domain/javascript/javascriptAstFingerprint.js +60 -33
- package/dist/domain/javascript/javascriptAstValues.js +54 -0
- package/dist/domain/javascript/javascriptElectronMemberWrites.js +50 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +3 -2
- package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +31 -23
- package/dist/domain/javascript/javascriptExportShapeSelection.js +2 -2
- package/dist/domain/javascript/javascriptExportShapeVariants.js +3 -2
- package/dist/domain/javascript/javascriptFeatureSeed.js +5 -3
- package/dist/domain/javascript/javascriptFeatureTrace.js +7 -6
- package/dist/domain/javascript/javascriptFeatureTraceSchemas.js +17 -9
- package/dist/domain/javascript/javascriptFeatureTraversal.js +4 -4
- package/dist/domain/javascript/javascriptModuleSemanticIr.js +15 -0
- package/dist/domain/javascript/javascriptNativeHandoff.js +12 -7
- package/dist/domain/javascript/javascriptRpcEndpoints.js +253 -0
- package/dist/domain/javascript/javascriptRuntimeLoadState.js +1 -3
- package/dist/domain/javascript/javascriptRuntimeObservation.js +8 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliation.js +12 -6
- package/dist/domain/javascript/javascriptRuntimeReconciliationActive.js +9 -8
- package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +212 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationGraph.js +12 -6
- package/dist/domain/javascript/javascriptRuntimeReconciliationInputValidation.js +28 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +5 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliationParsing.js +12 -223
- package/dist/domain/javascript/javascriptRuntimeReconciliationResult.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeReconciliationRuntime.js +15 -4
- package/dist/domain/javascript/javascriptRuntimeReconciliationSchemas.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +15 -17
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +379 -30
- package/dist/domain/javascript/javascriptSemanticCallResolution.js +9 -7
- package/dist/domain/javascript/javascriptSemanticCallableResults.js +42 -0
- package/dist/domain/javascript/javascriptSemanticCalls.js +8 -1
- package/dist/domain/javascript/javascriptSemanticChildProcesses.js +2 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +20 -0
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +7 -9
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +4 -11
- package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +15 -4
- package/dist/domain/javascript/javascriptSemanticFileProjection.js +1 -0
- package/dist/domain/javascript/javascriptSemanticFingerprints.js +43 -42
- package/dist/domain/javascript/javascriptSemanticGraph.js +205 -52
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +21 -11
- package/dist/domain/javascript/javascriptSemanticIr.js +0 -4
- package/dist/domain/javascript/javascriptSemanticIterationSources.js +139 -0
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +774 -136
- package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +190 -0
- package/dist/domain/javascript/javascriptSemanticMutationValues.js +98 -41
- package/dist/domain/javascript/javascriptSemanticObjectReferences.js +381 -0
- package/dist/domain/javascript/javascriptSemanticObjects.js +9 -7
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +7 -2
- package/dist/domain/javascript/javascriptSemanticProjection.js +72 -28
- package/dist/domain/javascript/javascriptSemanticPromises.js +15 -21
- package/dist/domain/javascript/javascriptSemanticPropertyPaths.js +100 -0
- package/dist/domain/javascript/javascriptSemanticProvenance.js +3 -3
- package/dist/domain/javascript/javascriptSemanticQuery.js +33 -29
- package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +4 -5
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -9
- package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +16 -10
- package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +219 -0
- package/dist/domain/javascript/javascriptSemanticReturns.js +34 -48
- package/dist/domain/javascript/javascriptSemanticState.js +22 -2
- package/dist/domain/javascript/javascriptSemanticTraversal.js +25 -2
- package/dist/domain/javascript/javascriptSemanticValues.js +169 -30
- package/dist/domain/javascript/javascriptSourceAnalysis.js +1 -0
- package/dist/domain/javascript/javascriptSourceMapPaths.js +11 -1
- package/dist/domain/javascript/javascriptSourceParser.js +34 -9
- package/dist/domain/javascript/javascriptStaticAnalysis.js +29 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +13 -12
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +49 -5
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +8 -4
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +26 -15
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +1 -0
- package/dist/domain/javascript/sourceToBundleComparison.js +7 -5
- package/dist/domain/javascript/sourceToBundleSignals.js +7 -7
- package/dist/domain/jeb/jebAnalysis.js +114 -0
- package/dist/domain/jsonSerialization.js +109 -55
- package/dist/domain/jsonShape.js +69 -31
- package/dist/domain/jsonValue.js +3 -0
- package/dist/domain/localPath.js +10 -4
- package/dist/domain/managed/managedApplicationGraph.js +47 -6
- package/dist/domain/managed/managedApplicationGraphCoverage.js +8 -2
- package/dist/domain/managed/managedApplicationGraphNodes.js +94 -59
- package/dist/domain/managed/managedArtifact.js +1 -0
- package/dist/domain/managed/managedInspectionEvidence.js +13 -0
- package/dist/domain/managed/managedMemberComparisonMatch.js +6 -7
- package/dist/domain/native/nativeAotPe.js +1408 -0
- package/dist/domain/native/nativeCallObservation.js +2 -4
- package/dist/domain/native/nativeInstruction.js +21 -0
- package/dist/domain/native/nativeMetadataRecovery.js +79 -6
- package/dist/domain/native/nativeValueFlow.js +5 -11
- package/dist/domain/native/objcSwiftMetadata.js +15 -17
- package/dist/domain/native/peResources.js +94 -0
- package/dist/domain/nativeConvention.js +33 -0
- package/dist/domain/process/processCapture.js +102 -11
- package/dist/domain/process/processCaptureCoverage.js +8 -5
- package/dist/domain/process/processCaptureExample.js +67 -0
- package/dist/domain/process/processCaptureValidation.js +83 -3
- package/dist/domain/process/processComparison.js +0 -23
- package/dist/domain/process/processScenario.js +62 -10
- package/dist/domain/process/processTraceEvaluation.js +4 -4
- package/dist/domain/process/processTraceSpecification.js +1 -3
- package/dist/domain/propertyListKeys.js +3 -1
- package/dist/domain/providerCleanupError.js +6 -2
- package/dist/domain/reconstructionCoverage.js +2 -1
- package/dist/domain/reconstructionUnknowns.js +4 -3
- package/dist/domain/reconstructionVerification.js +3 -2
- package/dist/domain/referenceSourceGraph.js +32 -23
- package/dist/domain/referenceSourceImportParsing.js +40 -48
- package/dist/domain/referenceSourcePathIdentity.js +22 -0
- package/dist/domain/referenceSourceRequireBindings.js +137 -0
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +2 -1
- package/dist/domain/swiftSymbolClassification.js +6 -1
- package/dist/domain/symbolAnalysis.js +17 -2
- package/dist/domain/unicodeCodePointOrder.js +6 -0
- package/dist/domain/webBundleAnalyzerInspection.js +23 -3
- package/dist/domain/webCaptureDiff.js +170 -30
- package/dist/domain/webCaptureDiffSchemas.js +2 -8
- package/dist/domain/webInventory.js +3 -2
- package/dist/domain/webMcpDiscovery.js +4 -3
- package/dist/domain/webScriptExport.js +1 -1
- package/dist/domain/webScriptExportError.js +10 -4
- package/dist/domain/webScriptExportPlan.js +7 -13
- package/dist/domain/zipPackageFormat.js +4 -1
- package/dist/domain/zodCollectionSteps.js +24 -0
- package/dist/dotnet/ManagedArtifactInspector.js +55 -43
- package/dist/dotnet/ManagedDecodeBudget.js +80 -0
- package/dist/dotnet/ManagedMemberInspector.js +13 -6
- package/dist/dotnet/ManagedMemberInspectorCore.js +2 -2
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +5 -4
- package/dist/dotnet/ManagedMemberRows.js +9 -4
- package/dist/dotnet/ManagedMetadataHeaps.js +15 -5
- package/dist/dotnet/ManagedMetadataInventoryRows.js +20 -11
- package/dist/dotnet/ManagedMetadataLayout.js +10 -4
- package/dist/dotnet/ManagedMethodBodyReader.js +8 -3
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +3 -2
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +49 -34
- package/dist/dotnet/ManagedPeReader.js +41 -25
- package/dist/dotnet/ManagedReaderFailure.js +2 -1
- package/dist/dotnet/ManagedStaticProvider.js +65 -31
- package/dist/dotnet/ManagedStaticProviderMetadata.js +1 -4
- package/dist/evaluation/AgentEvaluationReport.js +9 -5
- package/dist/evaluation/CodexAgentEval.js +43 -13
- package/dist/evm/EvmoleFailures.js +0 -2
- package/dist/evm/EvmoleInterfaceProvider.js +67 -2
- package/dist/filesystem/OwnedDirectoryHandle.js +29 -0
- package/dist/filesystem/OwnedFileHandle.js +36 -0
- package/dist/filesystem/RegularFile.js +73 -0
- package/dist/filesystem/StableFileHash.js +46 -0
- package/dist/filesystem/readFileHandleChunks.js +26 -0
- package/dist/firmware/FirmwareCommand.js +25 -3
- package/dist/firmware/FirmwareFiles.js +23 -8
- package/dist/firmware/FirmwareProvider.js +156 -32
- package/dist/firmware/FirmwarePublication.js +24 -3
- package/dist/firmware/FirmwareRelease.js +1 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +55 -4
- package/dist/ghidra/GhidraAnalysisSeeds.js +211 -0
- package/dist/ghidra/GhidraClient.js +90 -8
- package/dist/ghidra/GhidraDiagnostics.js +11 -8
- package/dist/ghidra/GhidraFunctionValues.js +26 -2
- package/dist/ghidra/GhidraInstallation.js +111 -10
- package/dist/ghidra/GhidraInventoryValues.js +23 -1
- package/dist/ghidra/GhidraLanguageCatalog.js +99 -0
- package/dist/ghidra/GhidraLauncher.js +123 -58
- package/dist/ghidra/GhidraLoadImageAttest.js +49 -2
- package/dist/ghidra/GhidraMipsProfile.js +79 -0
- package/dist/ghidra/GhidraProvider.js +57 -9
- package/dist/ghidra/GhidraProviderCapabilities.js +18 -8
- package/dist/ghidra/GhidraProviderClient.js +282 -21
- package/dist/ghidra/GhidraSessionValues.js +9 -2
- package/dist/hopper/HopperAnalysisProfile.js +2 -0
- package/dist/hopper/HopperCleanup.js +1 -1
- package/dist/hopper/HopperClient.js +15 -6
- package/dist/hopper/HopperMachOImage.js +2 -0
- package/dist/hopper/HopperProvider.js +13 -2
- package/dist/ida/IdaOperationRunner.js +10 -2
- package/dist/ida/IdaProvider.js +7 -0
- package/dist/ida/IdaSessionClient.js +7 -3
- package/dist/ida/IdaWorkspace.js +4 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -5
- package/dist/inspector/V8InspectorCaptureProjection.js +46 -13
- package/dist/inspector/V8InspectorProvider.js +60 -8
- package/dist/javascript/analysis/JavaScriptAnalysisTransfer.js +326 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorker.js +520 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerProtocol.js +63 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerSchemas.js +521 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerServer.js +116 -0
- package/dist/javascript/recovery/RecoveryFiles.js +18 -7
- package/dist/javascript/recovery/WakaruCommand.js +22 -9
- package/dist/javascript/recovery/WakaruExecution.js +11 -7
- package/dist/javascript/recovery/WakaruProvider.js +139 -16
- package/dist/javascript/recovery/WakaruPublication.js +14 -4
- package/dist/javascript/recovery/WakaruRelease.js +10 -3
- package/dist/javascript/recovery/WakaruReport.js +12 -7
- package/dist/javascript/recovery/WakaruVersion.js +24 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +16 -3
- package/dist/javascript/sourceMaps/SourceMapDecoder.js +63 -7
- package/dist/javascript/sourceMaps/SourceMapFormat.js +15 -4
- package/dist/jeb/JebMcpConnection.js +179 -0
- package/dist/jeb/JebMcpEndpoint.js +40 -0
- package/dist/jeb/JebProvider.js +299 -0
- package/dist/main/shutdown.js +76 -32
- package/dist/main/transport.js +1 -1
- package/dist/mcpDoctor.js +15 -6
- package/dist/native/AppleDispatchCoverage.js +25 -12
- package/dist/native/AppleDispatchMetadata.js +14 -7
- package/dist/native/AppleMachoFixups.js +71 -15
- package/dist/native/AppleMachoSelection.js +23 -3
- package/dist/native/AppleObjcDispatchFacets.js +3 -3
- package/dist/native/AppleObjcProperties.js +17 -7
- package/dist/native/LldbCallTracer.js +241 -75
- package/dist/native/NativeMacOSProvider.js +100 -20
- package/dist/native/NativeMacOSProviderMetadata.js +1 -2
- package/dist/native/NativeMachoInspection.js +11 -7
- package/dist/native/NativeUiHelperRuntime.js +6 -1
- package/dist/native/NativeUiObservation.js +4 -3
- package/dist/native/pe/PeResourceLayout.js +120 -0
- package/dist/native/pe/PeResourceParser.js +286 -0
- package/dist/native/pe/PeResourcesProvider.js +63 -0
- package/dist/process/BoundedFileBytes.js +30 -7
- package/dist/process/DarwinProcessRunTokenReader.js +8 -3
- package/dist/process/OwnedCommand.js +4 -3
- package/dist/process/ProcessOwnership.js +104 -112
- package/dist/process/ProcessOwnershipObservation.js +104 -51
- package/dist/process/ProcessOwnershipProcessTree.js +4 -4
- package/dist/process/ProcessRunTokenObservations.js +48 -0
- package/dist/process/ProviderDiagnosticRedaction.js +17 -0
- package/dist/process/ProviderProcess.js +4 -3
- package/dist/process/capture/FilesystemSnapshot.js +116 -22
- package/dist/process/capture/ProcessCaptureLifecycle.js +363 -86
- package/dist/process/capture/ProcessCaptureProgress.js +62 -0
- package/dist/process/capture/ProcessFilesystemEffects.js +19 -4
- package/dist/process/capture/ProcessHarness.js +202 -47
- package/dist/process/capture/ProcessNormalization.js +3 -1
- package/dist/process/capture/ProcessScenarioRuntimeValidation.js +5 -2
- package/dist/process/capture/TerminalRenderer.js +24 -7
- package/dist/reference/ReferenceSourceReader.js +22 -5
- package/dist/reference/ReferenceSourceReaderEntries.js +114 -51
- package/dist/reference/ReferenceSourceReaderErrors.js +12 -0
- package/dist/reference/ReferenceSourceReaderFile.js +50 -10
- package/dist/reference/ReferenceSourceReaderValidate.js +4 -4
- package/dist/server/EvidenceMcpServer.js +36 -1
- package/dist/server/admittedToolOperation.js +9 -0
- package/dist/server/analysisAdmission.js +8 -0
- package/dist/server/contractToolHandler.js +21 -0
- package/dist/server/createServer.js +118 -47
- package/dist/server/registerAdbTools.js +36 -0
- package/dist/server/registerAnalysisViewTool.js +4 -9
- package/dist/server/registerAndroidTools.js +3 -12
- package/dist/server/registerApktoolTools.js +14 -0
- package/dist/server/registerApplicationTools/compareExportShapes.js +6 -7
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +4 -5
- package/dist/server/registerApplicationTools/compareVersions.js +3 -2
- package/dist/server/registerApplicationTools/coverage.js +3 -2
- package/dist/server/registerApplicationTools/helpers.js +3 -2
- package/dist/server/registerApplicationTools/obligationLedger.js +3 -2
- package/dist/server/registerApplicationTools/projectMobileApplicationGraph.js +3 -2
- package/dist/server/registerApplicationTools/traceFeature.js +3 -2
- package/dist/server/registerApplicationTools/traceSemantics.js +4 -5
- package/dist/server/registerArtifactComparisonTool.js +5 -2
- package/dist/server/registerArtifactTools.js +2 -2
- package/dist/server/registerBinaryDiagnosticsTools.js +16 -4
- package/dist/server/registerBrowserScenarioTool.js +10 -7
- package/dist/server/registerBrowserTools.js +12 -9
- package/dist/server/registerBundleComparisonTool.js +16 -2
- package/dist/server/registerCloseLifecycleTool.js +36 -5
- package/dist/server/registerElectronTools.js +28 -10
- package/dist/server/registerEnhancedTools.js +78 -73
- package/dist/server/registerEvidenceTools.js +54 -46
- package/dist/server/registerEvmTools.js +4 -9
- package/dist/server/registerFirmwareTools.js +3 -11
- package/dist/server/registerFunctionComparisonTool.js +5 -2
- package/dist/server/registerJavaScriptRecoveryTool.js +4 -9
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +9 -6
- package/dist/server/registerJebTools.js +16 -0
- package/dist/server/registerManagedTools.js +7 -4
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +4 -6
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +3 -2
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +3 -2
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +3 -2
- package/dist/server/registerOfficialTools.js +31 -25
- package/dist/server/registerPeResourcesTool.js +9 -0
- package/dist/server/registerProcessComparisonTool.js +5 -2
- package/dist/server/registerRecordedCrashTools.js +4 -9
- package/dist/server/registerSessionRecordTools.js +2 -1
- package/dist/server/registerSessionTools.js +58 -21
- package/dist/server/registerWebModuleTool.js +4 -9
- package/dist/server/registerWebNetworkCaptureTool.js +4 -9
- package/dist/server/registerWebRuntimeTools.js +6 -5
- package/dist/server/registerWebScriptTool.js +6 -3
- package/dist/server/registerWebSourceLocationTool.js +4 -9
- package/dist/server/toolResult.js +21 -2
- package/dist/windows/WindowsPrivateRuntime.js +12 -5
- package/install.sh +7 -4
- package/licenses/nativeaot-parser-MIT.txt +28 -0
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +38 -7
- package/scripts/rea.mjs +16 -1
- package/skills/reverse-engineer-anything/SKILL.md +52 -51
- package/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +8 -0
- package/skills/reverse-engineer-anything/references/javascript-applications.md +92 -13
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +31 -1
- package/dist/artifacts/inventory/policy.js +0 -2
- package/dist/domain/managed/managedApplicationGraphNodeCoverage.js +0 -6
- package/dist/server/registerNativeTools.js +0 -6
|
@@ -1,69 +1,124 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { canonicalJson } from "../comparisonSemantics.js";
|
|
3
|
+
import { digestCanonicalValue } from "../canonicalDigest.js";
|
|
4
|
+
import { uniqueSorted } from "../canonicalOrdering.js";
|
|
5
|
+
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
4
6
|
import { canonicalJsonDigestSteps } from "../canonicalJsonDigestSteps.js";
|
|
5
7
|
import { freezeOwnedJsonSnapshotSteps } from "../immutableJson.js";
|
|
6
|
-
import {
|
|
8
|
+
import { arrayContainerSchema, parseElementSteps, } from "../zodCollectionSteps.js";
|
|
9
|
+
import { applicationGraphEvidenceSchema } from "./javascriptApplicationEvidenceSchemas.js";
|
|
10
|
+
import { JAVASCRIPT_SEMANTIC_RELATION_FAMILIES, JAVASCRIPT_SEMANTIC_RELATION_FAMILY, javaScriptSemanticFingerprintInputSchema, javaScriptSemanticEvidenceContextSchema, javaScriptSemanticGraphInputSchema, javaScriptSemanticGraphRecordSchema, javaScriptSemanticNodeInputSchema, javaScriptSemanticRelationInputSchema, javaScriptSemanticUnknownInputSchema, } from "./javascriptSemanticGraphSchemas.js";
|
|
7
11
|
const normalizeEvidence = (evidence) => ({
|
|
8
12
|
...evidence,
|
|
9
13
|
coverage: {
|
|
10
14
|
...evidence.coverage,
|
|
11
|
-
limits: [...evidence.coverage.limits].sort((left, right) =>
|
|
15
|
+
limits: [...evidence.coverage.limits].sort((left, right) => compareUnicodeCodePoints(canonicalJson(left, "JavaScript semantic graph"), canonicalJson(right, "JavaScript semantic graph"))),
|
|
12
16
|
},
|
|
13
17
|
limitations: uniqueSorted(evidence.limitations),
|
|
14
18
|
evidence_ids: uniqueSorted(evidence.evidence_ids),
|
|
15
19
|
});
|
|
20
|
+
const evidenceContextId = (context) => `jsrg_evidence_${digestCanonicalValue(context, "JavaScript semantic evidence context")}`;
|
|
21
|
+
/** Graph-scoped owner for canonical provenance shared by semantic facts. */
|
|
22
|
+
export class JavaScriptSemanticEvidenceContextRegistry {
|
|
23
|
+
#contexts = new Map();
|
|
24
|
+
// Facts share a few contexts, so key them by canonical text and hash each
|
|
25
|
+
// distinct context once instead of on every fact.
|
|
26
|
+
#idsByCanonicalContext = new Map();
|
|
27
|
+
/** Intern normalized non-location provenance at fact construction. */
|
|
28
|
+
intern(evidence) {
|
|
29
|
+
const normalized = normalizeEvidence(evidence);
|
|
30
|
+
const { location, ...context } = normalized;
|
|
31
|
+
const canonicalContext = canonicalJson(context, "JavaScript semantic graph");
|
|
32
|
+
const internedId = this.#idsByCanonicalContext.get(canonicalContext);
|
|
33
|
+
if (internedId !== undefined)
|
|
34
|
+
return { context_id: internedId, location };
|
|
35
|
+
const contextId = evidenceContextId(context);
|
|
36
|
+
// This canonical context is new, so a row already stored under its
|
|
37
|
+
// digest holds different provenance.
|
|
38
|
+
if (this.#contexts.has(contextId))
|
|
39
|
+
throw new TypeError("JavaScript semantic evidence context digest collision");
|
|
40
|
+
this.#contexts.set(contextId, { ...context, context_id: contextId });
|
|
41
|
+
this.#idsByCanonicalContext.set(canonicalContext, contextId);
|
|
42
|
+
return { context_id: contextId, location };
|
|
43
|
+
}
|
|
44
|
+
/** Resolve one already interned fact reference for derived evidence. */
|
|
45
|
+
resolve(reference) {
|
|
46
|
+
const context = this.#contexts.get(reference.context_id);
|
|
47
|
+
if (context === undefined)
|
|
48
|
+
throw new TypeError("Semantic evidence reference names an absent context");
|
|
49
|
+
const { context_id: _contextId, ...evidenceContext } = context;
|
|
50
|
+
return { ...evidenceContext, location: reference.location };
|
|
51
|
+
}
|
|
52
|
+
/** Return the deterministic context table owned by this graph projection. */
|
|
53
|
+
get contexts() {
|
|
54
|
+
return [...this.#contexts.values()].sort((left, right) => compareUnicodeCodePoints(left.context_id, right.context_id));
|
|
55
|
+
}
|
|
56
|
+
/** Release interned contexts after the owning graph is finalized. */
|
|
57
|
+
clear() {
|
|
58
|
+
this.#contexts.clear();
|
|
59
|
+
this.#idsByCanonicalContext.clear();
|
|
60
|
+
}
|
|
61
|
+
/** Validate and intern provenance decoded in this realm from an analysis worker. */
|
|
62
|
+
adopt(input) {
|
|
63
|
+
const context = javaScriptSemanticEvidenceContextSchema.parse(input);
|
|
64
|
+
const { context_id: identifier, ...value } = context;
|
|
65
|
+
if (identifier !== evidenceContextId(value))
|
|
66
|
+
throw new TypeError("Transferred semantic evidence context identifier is stale");
|
|
67
|
+
const canonical = canonicalJson(value, "JavaScript semantic evidence context");
|
|
68
|
+
const existing = this.#contexts.get(identifier);
|
|
69
|
+
if (existing !== undefined) {
|
|
70
|
+
const { context_id: _existingIdentifier, ...existingValue } = existing;
|
|
71
|
+
if (canonical !==
|
|
72
|
+
canonicalJson(existingValue, "JavaScript semantic evidence context"))
|
|
73
|
+
throw new TypeError("Transferred semantic evidence context digest collision");
|
|
74
|
+
}
|
|
75
|
+
this.#contexts.set(identifier, context);
|
|
76
|
+
this.#idsByCanonicalContext.set(canonical, identifier);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
16
79
|
/** Derive a semantic node ID from its kind and exact artifact identity. */
|
|
17
|
-
export const javaScriptSemanticNodeId = (node) => `jsrg_node_${
|
|
80
|
+
export const javaScriptSemanticNodeId = (node) => `jsrg_node_${digestCanonicalValue({ kind: node.kind, identity: node.identity }, "JavaScript semantic graph")}`;
|
|
18
81
|
/** Normalize one semantic entity and derive its artifact-version identifier. */
|
|
19
|
-
export const createJavaScriptSemanticGraphNode = (input) => {
|
|
82
|
+
export const createJavaScriptSemanticGraphNode = (input, evidenceContexts) => {
|
|
20
83
|
const parsed = javaScriptSemanticNodeInputSchema.parse(input);
|
|
21
84
|
const semantic = {
|
|
22
85
|
...parsed,
|
|
23
86
|
application_node_ids: uniqueSorted(parsed.application_node_ids),
|
|
24
|
-
evidence:
|
|
25
|
-
identifier_strategy: {
|
|
26
|
-
strategy: "semantic-content-sha256",
|
|
27
|
-
stability: "artifact-version",
|
|
28
|
-
},
|
|
87
|
+
evidence: evidenceContexts.intern(parsed.evidence),
|
|
29
88
|
};
|
|
30
|
-
return
|
|
89
|
+
return {
|
|
31
90
|
...semantic,
|
|
32
91
|
node_id: javaScriptSemanticNodeId(semantic),
|
|
33
|
-
}
|
|
92
|
+
};
|
|
34
93
|
};
|
|
35
94
|
/** Normalize one semantic relationship and derive its exact identifier. */
|
|
36
|
-
export const createJavaScriptSemanticGraphRelation = (input) => {
|
|
95
|
+
export const createJavaScriptSemanticGraphRelation = (input, evidenceContexts) => {
|
|
37
96
|
const parsed = javaScriptSemanticRelationInputSchema.parse(input);
|
|
38
97
|
const semantic = {
|
|
39
98
|
...parsed,
|
|
40
|
-
evidence:
|
|
41
|
-
identifier_strategy: {
|
|
42
|
-
strategy: "semantic-content-sha256",
|
|
43
|
-
stability: "relationship-exact",
|
|
44
|
-
},
|
|
99
|
+
evidence: evidenceContexts.intern(parsed.evidence),
|
|
45
100
|
};
|
|
46
|
-
return
|
|
101
|
+
return {
|
|
47
102
|
...semantic,
|
|
48
|
-
relation_id: `jsrg_relation_${
|
|
49
|
-
}
|
|
103
|
+
relation_id: `jsrg_relation_${digestCanonicalValue(semantic, "JavaScript semantic graph")}`,
|
|
104
|
+
};
|
|
50
105
|
};
|
|
51
106
|
/** Normalize one unresolved semantic frontier and derive its identifier. */
|
|
52
|
-
export const createJavaScriptSemanticGraphUnknown = (input) => {
|
|
107
|
+
export const createJavaScriptSemanticGraphUnknown = (input, evidenceContexts) => {
|
|
53
108
|
const parsed = javaScriptSemanticUnknownInputSchema.parse(input);
|
|
54
109
|
const semantic = {
|
|
55
110
|
...parsed,
|
|
56
111
|
relation_kinds: uniqueSorted(parsed.relation_kinds),
|
|
57
112
|
candidate_node_ids: uniqueSorted(parsed.candidate_node_ids),
|
|
58
|
-
evidence:
|
|
113
|
+
evidence: evidenceContexts.intern(parsed.evidence),
|
|
59
114
|
};
|
|
60
|
-
return
|
|
115
|
+
return {
|
|
61
116
|
...semantic,
|
|
62
|
-
unknown_id: `jsrg_unknown_${
|
|
63
|
-
}
|
|
117
|
+
unknown_id: `jsrg_unknown_${digestCanonicalValue(semantic, "JavaScript semantic graph")}`,
|
|
118
|
+
};
|
|
64
119
|
};
|
|
65
120
|
/** Normalize one function fingerprint and derive its component commitment. */
|
|
66
|
-
export const createJavaScriptSemanticFingerprint = (input) => {
|
|
121
|
+
export const createJavaScriptSemanticFingerprint = (input, evidenceContexts) => {
|
|
67
122
|
const parsed = javaScriptSemanticFingerprintInputSchema.parse(input);
|
|
68
123
|
const semantic = {
|
|
69
124
|
...parsed,
|
|
@@ -72,22 +127,22 @@ export const createJavaScriptSemanticFingerprint = (input) => {
|
|
|
72
127
|
effects: uniqueSorted(parsed.components.effects),
|
|
73
128
|
},
|
|
74
129
|
limitations: uniqueSorted(parsed.limitations),
|
|
75
|
-
evidence:
|
|
130
|
+
evidence: evidenceContexts.intern(parsed.evidence),
|
|
76
131
|
};
|
|
77
|
-
const fingerprintSha256 =
|
|
78
|
-
return
|
|
132
|
+
const fingerprintSha256 = digestCanonicalValue(semantic.components, "JavaScript semantic graph");
|
|
133
|
+
return {
|
|
79
134
|
...semantic,
|
|
80
135
|
fingerprint_sha256: fingerprintSha256,
|
|
81
|
-
fingerprint_id: `jsrg_fingerprint_${
|
|
136
|
+
fingerprint_id: `jsrg_fingerprint_${digestCanonicalValue({
|
|
82
137
|
function_node_id: semantic.function_node_id,
|
|
83
138
|
algorithm: semantic.algorithm,
|
|
84
139
|
fingerprint_sha256: fingerprintSha256,
|
|
85
140
|
}, "JavaScript semantic graph")}`,
|
|
86
|
-
}
|
|
141
|
+
};
|
|
87
142
|
};
|
|
88
143
|
const sortedUniqueIssue = (values, path, label, context) => {
|
|
89
144
|
for (let index = 1; index < values.length; index += 1) {
|
|
90
|
-
if (
|
|
145
|
+
if (compareUnicodeCodePoints(values[index - 1] ?? "", values[index] ?? "") < 0)
|
|
91
146
|
continue;
|
|
92
147
|
context.addIssue({
|
|
93
148
|
code: "custom",
|
|
@@ -159,12 +214,64 @@ function* checkCoverageSteps(graph, context) {
|
|
|
159
214
|
}
|
|
160
215
|
const checkCanonicalOrder = (graph, context) => {
|
|
161
216
|
sortedUniqueIssue(graph.root_node_ids, ["root_node_ids"], "Root nodes", context);
|
|
217
|
+
sortedUniqueIssue(graph.evidence_contexts.map(({ context_id }) => context_id), ["evidence_contexts"], "Evidence contexts", context);
|
|
162
218
|
sortedUniqueIssue(graph.nodes.map(({ node_id }) => node_id), ["nodes"], "Nodes", context);
|
|
163
219
|
sortedUniqueIssue(graph.relations.map(({ relation_id }) => relation_id), ["relations"], "Relations", context);
|
|
164
220
|
sortedUniqueIssue(graph.fingerprints.map(({ fingerprint_id }) => fingerprint_id), ["fingerprints"], "Fingerprints", context);
|
|
165
221
|
sortedUniqueIssue(graph.unknowns.map(({ unknown_id }) => unknown_id), ["unknowns"], "Unknown frontiers", context);
|
|
166
222
|
sortedUniqueIssue(graph.limitations, ["limitations"], "Limitations", context);
|
|
167
223
|
};
|
|
224
|
+
function* checkEvidenceContextReferencesSteps(graph, context) {
|
|
225
|
+
const contexts = new Map(graph.evidence_contexts.map((value) => [value.context_id, value]));
|
|
226
|
+
const referenced = new Set();
|
|
227
|
+
const validateReferences = function* (entities, entityKind) {
|
|
228
|
+
for (const [index, { evidence }] of entities.entries()) {
|
|
229
|
+
if (index % 256 === 0)
|
|
230
|
+
yield;
|
|
231
|
+
referenced.add(evidence.context_id);
|
|
232
|
+
const evidenceContext = contexts.get(evidence.context_id);
|
|
233
|
+
if (evidenceContext === undefined) {
|
|
234
|
+
context.addIssue({
|
|
235
|
+
code: "custom",
|
|
236
|
+
path: [entityKind, index, "evidence", "context_id"],
|
|
237
|
+
message: "Evidence reference names an absent context",
|
|
238
|
+
});
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
const { context_id: _contextId, ...evidenceValue } = evidenceContext;
|
|
242
|
+
if (!applicationGraphEvidenceSchema.safeParse({
|
|
243
|
+
...evidenceValue,
|
|
244
|
+
location: evidence.location,
|
|
245
|
+
}).success)
|
|
246
|
+
context.addIssue({
|
|
247
|
+
code: "custom",
|
|
248
|
+
path: [entityKind, index, "evidence"],
|
|
249
|
+
message: "Evidence context is incompatible with its fact location",
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
yield* validateReferences(graph.nodes, "nodes");
|
|
254
|
+
yield* validateReferences(graph.relations, "relations");
|
|
255
|
+
yield* validateReferences(graph.unknowns, "unknowns");
|
|
256
|
+
yield* validateReferences(graph.fingerprints, "fingerprints");
|
|
257
|
+
for (const [index, evidenceContext] of graph.evidence_contexts.entries()) {
|
|
258
|
+
if (index % 256 === 0)
|
|
259
|
+
yield;
|
|
260
|
+
const { context_id: identifier, ...value } = evidenceContext;
|
|
261
|
+
if (identifier !== evidenceContextId(value))
|
|
262
|
+
context.addIssue({
|
|
263
|
+
code: "custom",
|
|
264
|
+
path: ["evidence_contexts", index, "context_id"],
|
|
265
|
+
message: "Evidence context identifier is stale",
|
|
266
|
+
});
|
|
267
|
+
if (!referenced.has(identifier))
|
|
268
|
+
context.addIssue({
|
|
269
|
+
code: "custom",
|
|
270
|
+
path: ["evidence_contexts", index],
|
|
271
|
+
message: "Evidence context is not referenced by a graph fact",
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
168
275
|
function* checkNodesSteps(graph, nodes, context) {
|
|
169
276
|
for (const [index, node] of graph.nodes.entries()) {
|
|
170
277
|
if (index % 256 === 0)
|
|
@@ -196,13 +303,14 @@ function* checkRootsSteps(graph, nodes, context) {
|
|
|
196
303
|
});
|
|
197
304
|
}
|
|
198
305
|
}
|
|
199
|
-
function* checkRelationsSteps(graph, nodes, context) {
|
|
306
|
+
function* checkRelationsSteps(graph, nodes, evidenceContexts, context) {
|
|
200
307
|
for (const [index, relation] of graph.relations.entries()) {
|
|
201
308
|
if (index % 256 === 0)
|
|
202
309
|
yield;
|
|
203
310
|
const { relation_id: identifier, ...semantic } = relation;
|
|
204
311
|
if (identifier !==
|
|
205
|
-
"jsrg_relation_" +
|
|
312
|
+
"jsrg_relation_" +
|
|
313
|
+
digestCanonicalValue(semantic, "JavaScript semantic graph"))
|
|
206
314
|
context.addIssue({
|
|
207
315
|
code: "custom",
|
|
208
316
|
path: ["relations", index, "relation_id"],
|
|
@@ -222,7 +330,7 @@ function* checkRelationsSteps(graph, nodes, context) {
|
|
|
222
330
|
message: "Semantic relations cannot be self-referential",
|
|
223
331
|
});
|
|
224
332
|
if (relation.resolution === "candidate" &&
|
|
225
|
-
relation.evidence.state === "observed")
|
|
333
|
+
evidenceContexts.get(relation.evidence.context_id)?.state === "observed")
|
|
226
334
|
context.addIssue({
|
|
227
335
|
code: "custom",
|
|
228
336
|
path: ["relations", index, "evidence", "state"],
|
|
@@ -230,13 +338,14 @@ function* checkRelationsSteps(graph, nodes, context) {
|
|
|
230
338
|
});
|
|
231
339
|
}
|
|
232
340
|
}
|
|
233
|
-
function* checkUnknownsSteps(graph, nodes, context) {
|
|
341
|
+
function* checkUnknownsSteps(graph, nodes, evidenceContexts, context) {
|
|
234
342
|
for (const [index, unknown] of graph.unknowns.entries()) {
|
|
235
343
|
if (index % 256 === 0)
|
|
236
344
|
yield;
|
|
237
345
|
const { unknown_id: identifier, ...semantic } = unknown;
|
|
238
346
|
if (identifier !==
|
|
239
|
-
"jsrg_unknown_" +
|
|
347
|
+
"jsrg_unknown_" +
|
|
348
|
+
digestCanonicalValue(semantic, "JavaScript semantic graph"))
|
|
240
349
|
context.addIssue({
|
|
241
350
|
code: "custom",
|
|
242
351
|
path: ["unknowns", index, "unknown_id"],
|
|
@@ -260,7 +369,8 @@ function* checkUnknownsSteps(graph, nodes, context) {
|
|
|
260
369
|
path: ["unknowns", index, "relation_kinds"],
|
|
261
370
|
message: "Unknown relation kinds must belong to their declared family",
|
|
262
371
|
});
|
|
263
|
-
|
|
372
|
+
const evidenceState = evidenceContexts.get(unknown.evidence.context_id)?.state;
|
|
373
|
+
if (evidenceState !== "unknown" && evidenceState !== "unavailable")
|
|
264
374
|
context.addIssue({
|
|
265
375
|
code: "custom",
|
|
266
376
|
path: ["unknowns", index, "evidence", "state"],
|
|
@@ -289,14 +399,14 @@ function* checkFingerprintsSteps(graph, nodes, context) {
|
|
|
289
399
|
message: "Fingerprint must name a function node",
|
|
290
400
|
});
|
|
291
401
|
if (fingerprint.fingerprint_sha256 !==
|
|
292
|
-
|
|
402
|
+
digestCanonicalValue(fingerprint.components, "JavaScript semantic graph"))
|
|
293
403
|
context.addIssue({
|
|
294
404
|
code: "custom",
|
|
295
405
|
path: ["fingerprints", index, "fingerprint_sha256"],
|
|
296
406
|
message: "Fingerprint component commitment is stale",
|
|
297
407
|
});
|
|
298
408
|
const expectedIdentifier = "jsrg_fingerprint_" +
|
|
299
|
-
|
|
409
|
+
digestCanonicalValue({
|
|
300
410
|
function_node_id: fingerprint.function_node_id,
|
|
301
411
|
algorithm: fingerprint.algorithm,
|
|
302
412
|
fingerprint_sha256: fingerprint.fingerprint_sha256,
|
|
@@ -318,6 +428,11 @@ function* checkFingerprintsSteps(graph, nodes, context) {
|
|
|
318
428
|
}
|
|
319
429
|
function* checkGraphContentSteps(graph, context) {
|
|
320
430
|
checkCanonicalOrder(graph, context);
|
|
431
|
+
yield* checkEvidenceContextReferencesSteps(graph, context);
|
|
432
|
+
const evidenceContexts = new Map(graph.evidence_contexts.map((evidenceContext) => [
|
|
433
|
+
evidenceContext.context_id,
|
|
434
|
+
evidenceContext,
|
|
435
|
+
]));
|
|
321
436
|
const nodes = new Map();
|
|
322
437
|
for (const [index, node] of graph.nodes.entries()) {
|
|
323
438
|
if (index % 256 === 0)
|
|
@@ -326,8 +441,8 @@ function* checkGraphContentSteps(graph, context) {
|
|
|
326
441
|
}
|
|
327
442
|
yield* checkNodesSteps(graph, nodes, context);
|
|
328
443
|
yield* checkRootsSteps(graph, nodes, context);
|
|
329
|
-
yield* checkRelationsSteps(graph, nodes, context);
|
|
330
|
-
yield* checkUnknownsSteps(graph, nodes, context);
|
|
444
|
+
yield* checkRelationsSteps(graph, nodes, evidenceContexts, context);
|
|
445
|
+
yield* checkUnknownsSteps(graph, nodes, evidenceContexts, context);
|
|
331
446
|
checkUnknownReferences(graph, context);
|
|
332
447
|
yield* checkFingerprintsSteps(graph, nodes, context);
|
|
333
448
|
yield* checkCoverageSteps(graph, context);
|
|
@@ -348,7 +463,7 @@ const checkGraph = (graph, context) => {
|
|
|
348
463
|
checkGraphContent(graph, context);
|
|
349
464
|
const { graph_id: identifier, ...semantic } = graph;
|
|
350
465
|
if (identifier !==
|
|
351
|
-
"jsrg_" +
|
|
466
|
+
"jsrg_" + digestCanonicalValue(semantic, "JavaScript semantic graph"))
|
|
352
467
|
context.addIssue({
|
|
353
468
|
code: "custom",
|
|
354
469
|
path: ["graph_id"],
|
|
@@ -357,22 +472,31 @@ const checkGraph = (graph, context) => {
|
|
|
357
472
|
};
|
|
358
473
|
/** Strict semantic graph schema with verified canonical commitments. */
|
|
359
474
|
export const javaScriptSemanticGraphSchema = javaScriptSemanticGraphRecordSchema.superRefine(checkGraph);
|
|
475
|
+
/** Resolve one fact's compact provenance without changing its stored shape. */
|
|
476
|
+
export const resolveJavaScriptSemanticEvidence = (graph, reference) => {
|
|
477
|
+
const context = graph.evidence_contexts.find(({ context_id }) => context_id === reference.context_id);
|
|
478
|
+
if (context === undefined)
|
|
479
|
+
throw new TypeError("Semantic evidence reference names an absent context");
|
|
480
|
+
const { context_id: _contextId, ...evidenceContext } = context;
|
|
481
|
+
return { ...evidenceContext, location: reference.location };
|
|
482
|
+
};
|
|
360
483
|
const normalizeGraphInput = (parsed) => ({
|
|
361
484
|
...parsed,
|
|
362
485
|
root_node_ids: uniqueSorted(parsed.root_node_ids),
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
486
|
+
evidence_contexts: [...parsed.evidence_contexts].sort((left, right) => compareUnicodeCodePoints(left.context_id, right.context_id)),
|
|
487
|
+
nodes: [...parsed.nodes].sort((left, right) => compareUnicodeCodePoints(left.node_id, right.node_id)),
|
|
488
|
+
relations: [...parsed.relations].sort((left, right) => compareUnicodeCodePoints(left.relation_id, right.relation_id)),
|
|
489
|
+
fingerprints: [...parsed.fingerprints].sort((left, right) => compareUnicodeCodePoints(left.fingerprint_id, right.fingerprint_id)),
|
|
490
|
+
unknowns: [...parsed.unknowns].sort((left, right) => compareUnicodeCodePoints(left.unknown_id, right.unknown_id)),
|
|
367
491
|
coverage: {
|
|
368
492
|
...parsed.coverage,
|
|
369
|
-
limits: [...parsed.coverage.limits].sort((left, right) =>
|
|
493
|
+
limits: [...parsed.coverage.limits].sort((left, right) => compareUnicodeCodePoints(canonicalJson(left, "JavaScript semantic graph"), canonicalJson(right, "JavaScript semantic graph"))),
|
|
370
494
|
families: [...parsed.coverage.families]
|
|
371
495
|
.map((family) => ({
|
|
372
496
|
...family,
|
|
373
497
|
unknown_ids: uniqueSorted(family.unknown_ids),
|
|
374
498
|
}))
|
|
375
|
-
.sort((left, right) =>
|
|
499
|
+
.sort((left, right) => compareUnicodeCodePoints(left.family, right.family)),
|
|
376
500
|
},
|
|
377
501
|
limitations: uniqueSorted(parsed.limitations),
|
|
378
502
|
});
|
|
@@ -384,7 +508,7 @@ export const createJavaScriptSemanticGraph = (input) => {
|
|
|
384
508
|
// public schema still verifies arbitrary records and their commitments.
|
|
385
509
|
const record = {
|
|
386
510
|
...semantic,
|
|
387
|
-
graph_id: `jsrg_${
|
|
511
|
+
graph_id: `jsrg_${digestCanonicalValue(semantic, "JavaScript semantic graph")}`,
|
|
388
512
|
};
|
|
389
513
|
const issues = [];
|
|
390
514
|
checkGraphContent(record, {
|
|
@@ -397,8 +521,37 @@ export const createJavaScriptSemanticGraph = (input) => {
|
|
|
397
521
|
return record;
|
|
398
522
|
};
|
|
399
523
|
const validatedImmutableSemanticGraphs = new WeakSet();
|
|
524
|
+
const semanticGraphShape = javaScriptSemanticGraphInputSchema.shape;
|
|
525
|
+
const semanticGraphContainerSchema = javaScriptSemanticGraphInputSchema.extend({
|
|
526
|
+
evidence_contexts: arrayContainerSchema(semanticGraphShape.evidence_contexts),
|
|
527
|
+
nodes: arrayContainerSchema(semanticGraphShape.nodes),
|
|
528
|
+
relations: arrayContainerSchema(semanticGraphShape.relations),
|
|
529
|
+
fingerprints: arrayContainerSchema(semanticGraphShape.fingerprints),
|
|
530
|
+
unknowns: arrayContainerSchema(semanticGraphShape.unknowns),
|
|
531
|
+
});
|
|
400
532
|
/** Clone input synchronously; commit, check and seal the owned graph in steps. */
|
|
401
533
|
export const createImmutableJavaScriptSemanticGraphSteps = (input) => validateAndSealSemanticGraphSteps(normalizeGraphInput(javaScriptSemanticGraphInputSchema.parse(input)));
|
|
534
|
+
/**
|
|
535
|
+
* Seal a graph whose input the caller transfers: the caller neither retains nor
|
|
536
|
+
* mutates any part of it afterwards. Only the graph's own fields are validated
|
|
537
|
+
* synchronously; collection elements are validated and cloned in steps, because
|
|
538
|
+
* a whole-graph parse of a large application held the event loop for seconds.
|
|
539
|
+
*/
|
|
540
|
+
export const sealTransferredJavaScriptSemanticGraphSteps = (input) => parseAndSealSemanticGraphSteps(semanticGraphContainerSchema.parse(input));
|
|
541
|
+
function* parseAndSealSemanticGraphSteps(container) {
|
|
542
|
+
const issues = [];
|
|
543
|
+
const parsed = {
|
|
544
|
+
...container,
|
|
545
|
+
evidence_contexts: yield* parseElementSteps(semanticGraphShape.evidence_contexts.element, container.evidence_contexts, ["evidence_contexts"], issues),
|
|
546
|
+
nodes: yield* parseElementSteps(semanticGraphShape.nodes.element, container.nodes, ["nodes"], issues),
|
|
547
|
+
relations: yield* parseElementSteps(semanticGraphShape.relations.element, container.relations, ["relations"], issues),
|
|
548
|
+
fingerprints: yield* parseElementSteps(semanticGraphShape.fingerprints.element, container.fingerprints, ["fingerprints"], issues),
|
|
549
|
+
unknowns: yield* parseElementSteps(semanticGraphShape.unknowns.element, container.unknowns, ["unknowns"], issues),
|
|
550
|
+
};
|
|
551
|
+
if (issues.length > 0)
|
|
552
|
+
throw new z.ZodError(issues);
|
|
553
|
+
return yield* validateAndSealSemanticGraphSteps(normalizeGraphInput(parsed));
|
|
554
|
+
}
|
|
402
555
|
function* validateAndSealSemanticGraphSteps(semantic) {
|
|
403
556
|
const graph = {
|
|
404
557
|
...semantic,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { applicationGraphEvidenceSchema } from "./javascriptApplicationEvidenceSchemas.js";
|
|
2
|
+
import { applicationGraphEvidenceContextSchema, applicationGraphEvidenceLocationSchema, applicationGraphEvidenceSchema, } from "./javascriptApplicationEvidenceSchemas.js";
|
|
3
3
|
import { jsonValueSchema } from "../jsonValue.js";
|
|
4
4
|
import { digestSchema } from "../digests.js";
|
|
5
5
|
import { prefixedDigestSchema } from "../digests.js";
|
|
@@ -11,6 +11,18 @@ const semanticRelationIdSchema = z
|
|
|
11
11
|
const semanticUnknownIdSchema = z
|
|
12
12
|
.string()
|
|
13
13
|
.regex(/^jsrg_unknown_[a-f0-9]{64}$/u);
|
|
14
|
+
const semanticEvidenceContextIdSchema = z
|
|
15
|
+
.string()
|
|
16
|
+
.regex(/^jsrg_evidence_[a-f0-9]{64}$/u);
|
|
17
|
+
/** One canonical owner for provenance shared by semantic graph facts. */
|
|
18
|
+
export const javaScriptSemanticEvidenceContextSchema = applicationGraphEvidenceContextSchema.extend({
|
|
19
|
+
context_id: semanticEvidenceContextIdSchema,
|
|
20
|
+
});
|
|
21
|
+
/** Location-specific reference to one exact graph-level evidence context. */
|
|
22
|
+
export const javaScriptSemanticEvidenceReferenceSchema = z.strictObject({
|
|
23
|
+
context_id: semanticEvidenceContextIdSchema,
|
|
24
|
+
location: applicationGraphEvidenceLocationSchema,
|
|
25
|
+
});
|
|
14
26
|
/** Semantic entity kinds admitted by JavaScript Semantic Relation Graph. */
|
|
15
27
|
export const JAVASCRIPT_SEMANTIC_NODE_KINDS = [
|
|
16
28
|
"module",
|
|
@@ -188,11 +200,8 @@ export const javaScriptSemanticNodeInputSchema = z.strictObject({
|
|
|
188
200
|
});
|
|
189
201
|
/** One exact, artifact-version semantic entity. */
|
|
190
202
|
export const javaScriptSemanticNodeSchema = javaScriptSemanticNodeInputSchema.extend({
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
strategy: z.literal("semantic-content-sha256"),
|
|
194
|
-
stability: z.literal("artifact-version"),
|
|
195
|
-
}),
|
|
203
|
+
evidence: javaScriptSemanticEvidenceReferenceSchema,
|
|
204
|
+
node_id: semanticNodeIdSchema.describe("SHA-256 of the node kind and identity; stable for one artifact version."),
|
|
196
205
|
});
|
|
197
206
|
/** One directed semantic relationship before its ID is derived. */
|
|
198
207
|
export const javaScriptSemanticRelationInputSchema = z.strictObject({
|
|
@@ -205,11 +214,8 @@ export const javaScriptSemanticRelationInputSchema = z.strictObject({
|
|
|
205
214
|
});
|
|
206
215
|
/** One canonical directed semantic relationship. */
|
|
207
216
|
export const javaScriptSemanticRelationSchema = javaScriptSemanticRelationInputSchema.extend({
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
strategy: z.literal("semantic-content-sha256"),
|
|
211
|
-
stability: z.literal("relationship-exact"),
|
|
212
|
-
}),
|
|
217
|
+
evidence: javaScriptSemanticEvidenceReferenceSchema,
|
|
218
|
+
relation_id: semanticRelationIdSchema.describe("SHA-256 of the exact relation content, including its evidence reference."),
|
|
213
219
|
});
|
|
214
220
|
/** Reasons semantic analysis can leave an explicit frontier. */
|
|
215
221
|
export const JAVASCRIPT_SEMANTIC_UNKNOWN_REASONS = [
|
|
@@ -222,6 +228,7 @@ export const JAVASCRIPT_SEMANTIC_UNKNOWN_REASONS = [
|
|
|
222
228
|
"incomplete-module",
|
|
223
229
|
"missing-source",
|
|
224
230
|
"resource-limit",
|
|
231
|
+
"unknown-value",
|
|
225
232
|
"unsupported-syntax",
|
|
226
233
|
];
|
|
227
234
|
/** One unresolved semantic frontier before its ID is derived. */
|
|
@@ -236,6 +243,7 @@ export const javaScriptSemanticUnknownInputSchema = z.strictObject({
|
|
|
236
243
|
});
|
|
237
244
|
/** One canonical unresolved semantic frontier. */
|
|
238
245
|
export const javaScriptSemanticUnknownSchema = javaScriptSemanticUnknownInputSchema.extend({
|
|
246
|
+
evidence: javaScriptSemanticEvidenceReferenceSchema,
|
|
239
247
|
unknown_id: semanticUnknownIdSchema,
|
|
240
248
|
});
|
|
241
249
|
const fingerprintComponentsSchema = z.strictObject({
|
|
@@ -265,6 +273,7 @@ export const javaScriptSemanticFingerprintInputSchema = z.strictObject({
|
|
|
265
273
|
});
|
|
266
274
|
/** One canonical function fingerprint record. */
|
|
267
275
|
export const javaScriptSemanticFingerprintSchema = javaScriptSemanticFingerprintInputSchema.extend({
|
|
276
|
+
evidence: javaScriptSemanticEvidenceReferenceSchema,
|
|
268
277
|
fingerprint_id: prefixedDigestSchema("jsrg_fingerprint"),
|
|
269
278
|
fingerprint_sha256: digestSchema,
|
|
270
279
|
});
|
|
@@ -293,6 +302,7 @@ export const javaScriptSemanticGraphInputSchema = z.strictObject({
|
|
|
293
302
|
root_artifact_sha256: digestSchema,
|
|
294
303
|
application_graph_id: prefixedDigestSchema("jag"),
|
|
295
304
|
root_node_ids: z.array(semanticNodeIdSchema).min(1),
|
|
305
|
+
evidence_contexts: z.array(javaScriptSemanticEvidenceContextSchema),
|
|
296
306
|
nodes: z.array(javaScriptSemanticNodeSchema).min(1),
|
|
297
307
|
relations: z.array(javaScriptSemanticRelationSchema),
|
|
298
308
|
fingerprints: z.array(javaScriptSemanticFingerprintSchema),
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/** Find the innermost resolved reference at one source coordinate. */
|
|
2
|
-
export const semanticReferenceAt = (ir, line, column) => ir.references.find(({ location }) => location.start.line === line && location.start.column === column);
|
|
3
|
-
/** Read one binding by its deterministic semantic identifier. */
|
|
4
|
-
export const semanticBinding = (ir, bindingId) => ir.bindings.find(({ bindingId: candidate }) => candidate === bindingId);
|
|
5
1
|
/** Fail-closed result when Babel cannot produce an inert syntax tree. */
|
|
6
2
|
export const failedJavaScriptSemanticIr = () => ({
|
|
7
3
|
schema: "JavaScriptSemanticIR",
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import { semanticObjectPatternKeys, semanticStaticPropertyKey, } from "./javascriptAstValues.js";
|
|
3
|
+
import { semanticArrayIndex, } from "./javascriptSemanticPropertyPaths.js";
|
|
4
|
+
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
5
|
+
const add = (sources, source, mutation, guards, kind = "iteration") => {
|
|
6
|
+
sources.push({
|
|
7
|
+
kind,
|
|
8
|
+
node: source.node,
|
|
9
|
+
projection: source.projection,
|
|
10
|
+
mutation,
|
|
11
|
+
...guards,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const project = (source, key) => {
|
|
15
|
+
if (source === undefined)
|
|
16
|
+
return undefined;
|
|
17
|
+
const index = key === null ? null : semanticArrayIndex(key);
|
|
18
|
+
return {
|
|
19
|
+
node: source.node,
|
|
20
|
+
projection: [
|
|
21
|
+
...source.projection,
|
|
22
|
+
source.restStartIndex !== undefined && index !== null
|
|
23
|
+
? source.restStartIndex + index
|
|
24
|
+
: key,
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const visit = (context, pattern, source, guards = {}) => {
|
|
29
|
+
const { sources, mutation } = context;
|
|
30
|
+
if (t.isMemberExpression(pattern)) {
|
|
31
|
+
// Property stores have no lexical alias binding. Preserve the selected
|
|
32
|
+
// reference's escape rather than claiming later writes cannot reach it.
|
|
33
|
+
if (source !== undefined)
|
|
34
|
+
add(sources, source.restStartIndex === undefined
|
|
35
|
+
? source
|
|
36
|
+
: {
|
|
37
|
+
node: source.node,
|
|
38
|
+
projection: [
|
|
39
|
+
...source.projection,
|
|
40
|
+
{ excludedKeys: [], startIndex: source.restStartIndex },
|
|
41
|
+
],
|
|
42
|
+
}, mutation, guards, "reference-store");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (t.isTSParameterProperty(pattern)) {
|
|
46
|
+
visit(context, pattern.parameter, source, guards);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (t.isAssignmentPattern(pattern)) {
|
|
50
|
+
visit(context, pattern.left, source, {
|
|
51
|
+
...guards,
|
|
52
|
+
requiredSources: [
|
|
53
|
+
...(guards.requiredSources ?? []),
|
|
54
|
+
...(source === undefined ? [] : [source]),
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
visit(context, pattern.left, { node: pattern.right, projection: [] }, {
|
|
58
|
+
...guards,
|
|
59
|
+
fallbackSources: [
|
|
60
|
+
...(guards.fallbackSources ?? []),
|
|
61
|
+
...(source === undefined ? [] : [source]),
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (t.isObjectPattern(pattern)) {
|
|
67
|
+
for (const property of pattern.properties) {
|
|
68
|
+
if (t.isRestElement(property)) {
|
|
69
|
+
// A rest copy owns its scalar slots; only selected child references
|
|
70
|
+
// escape when that fresh copy is stored through a member target.
|
|
71
|
+
visit(context, property.argument, source === undefined
|
|
72
|
+
? undefined
|
|
73
|
+
: {
|
|
74
|
+
node: source.node,
|
|
75
|
+
projection: [
|
|
76
|
+
...source.projection,
|
|
77
|
+
{
|
|
78
|
+
excludedKeys: [
|
|
79
|
+
...new Set(semanticObjectPatternKeys(pattern)),
|
|
80
|
+
].sort(compareUnicodeCodePoints),
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
}, guards);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
visit(context, property.value, project(source, semanticStaticPropertyKey(property.key, property.computed)), guards);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (t.isArrayPattern(pattern)) {
|
|
91
|
+
if (source !== undefined && source.restStartIndex === undefined)
|
|
92
|
+
add(sources, source, mutation, guards);
|
|
93
|
+
pattern.elements.forEach((element, index) => {
|
|
94
|
+
if (element === null)
|
|
95
|
+
return;
|
|
96
|
+
if (t.isRestElement(element))
|
|
97
|
+
visit(context, element.argument, source === undefined
|
|
98
|
+
? undefined
|
|
99
|
+
: {
|
|
100
|
+
node: source.node,
|
|
101
|
+
projection: source.projection,
|
|
102
|
+
restStartIndex: (source.restStartIndex ?? 0) + index,
|
|
103
|
+
}, guards);
|
|
104
|
+
else
|
|
105
|
+
visit(context, element, project(source, index), guards);
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (t.isRestElement(pattern))
|
|
110
|
+
visit(context, pattern.argument, undefined, guards);
|
|
111
|
+
};
|
|
112
|
+
/** Describe iterator receivers and property reference stores without evaluation. */
|
|
113
|
+
export const semanticIterationSources = (node, parent) => {
|
|
114
|
+
const sources = [];
|
|
115
|
+
const context = { sources, mutation: node };
|
|
116
|
+
if (t.isVariableDeclarator(node) && node.init != null)
|
|
117
|
+
visit(context, node.id, { node: node.init, projection: [] });
|
|
118
|
+
else if (t.isAssignmentExpression(node) &&
|
|
119
|
+
["=", "||=", "&&=", "??="].includes(node.operator))
|
|
120
|
+
visit(context, node.left, { node: node.right, projection: [] });
|
|
121
|
+
else if (t.isForOfStatement(node)) {
|
|
122
|
+
add(sources, { node: node.right, projection: [] }, node, {});
|
|
123
|
+
const source = { node: node.right, projection: [null] };
|
|
124
|
+
if (t.isVariableDeclaration(node.left)) {
|
|
125
|
+
for (const declaration of node.left.declarations)
|
|
126
|
+
visit(context, declaration.id, source);
|
|
127
|
+
}
|
|
128
|
+
else
|
|
129
|
+
visit(context, node.left, source);
|
|
130
|
+
}
|
|
131
|
+
else if (t.isSpreadElement(node) && t.isArrayExpression(parent))
|
|
132
|
+
add(sources, { node: node.argument, projection: [] }, node, {});
|
|
133
|
+
else if (t.isYieldExpression(node) && node.delegate && node.argument != null)
|
|
134
|
+
add(sources, { node: node.argument, projection: [] }, node, {});
|
|
135
|
+
else if (t.isFunction(node))
|
|
136
|
+
for (const parameter of node.params)
|
|
137
|
+
visit(context, parameter, undefined);
|
|
138
|
+
return sources;
|
|
139
|
+
};
|