rea-agents 5.0.0 → 6.0.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 +157 -650
- package/bridge/mitmproxy/capture.py +210 -0
- package/bridge/native/rea_lldb_tracer.py +303 -0
- package/bridge/process/ProcessRunTokenReader.swift +263 -0
- package/bridge/process/ProcessRunTokenReaderMain.swift +35 -0
- package/bridge/pwndbg/core_context.py +101 -0
- package/bridge/pwndbg/launch.py +39 -0
- package/bridge/pwndbg/launch_impl.py +34 -0
- package/bridge/pwntools/decoder_runtime.py +59 -0
- package/bridge/pwntools/layout.py +39 -0
- package/bridge/pwntools/layout_impl.py +309 -0
- package/bridge/pwntools/recorded_crash.py +39 -0
- package/bridge/pwntools/recorded_crash_impl.py +143 -0
- package/dist/android/JadxProvider.js +1 -0
- package/dist/application/CapabilityInventory.js +21 -0
- package/dist/application/DirectAnalysis.js +97 -23
- package/dist/application/EvidenceBundleFiles.js +1 -1
- package/dist/application/ReconstructionObligationCandidates.js +5 -1
- package/dist/application/WebNetworkCapturePort.js +1 -0
- package/dist/application/WebNetworkCaptureService.js +132 -0
- package/dist/application/WindowsCapabilities.js +1 -1
- package/dist/application/binary/AnalysisSnapshotCache.js +49 -6
- package/dist/application/binary/BinarySession.js +38 -10
- package/dist/application/binary/BinarySessionOpen.js +16 -3
- package/dist/application/binary/BinarySessionRecords.js +20 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutPort.js +1 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +57 -0
- package/dist/application/binaryDiagnostics/RecordedCrashPort.js +1 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +60 -0
- package/dist/application/evm/EvmInterfacePort.js +1 -0
- package/dist/application/evm/EvmInterfaceService.js +62 -0
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +1 -2
- package/dist/application/javascript/JavaScriptApplicationService.js +15 -2
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +42 -23
- package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +26 -2
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +74 -24
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +23 -10
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +7 -7
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +145 -70
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +14 -15
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +41 -1
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +7 -7
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -9
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +118 -12
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +5 -5
- package/dist/application/{ProcessCli.js → process/ProcessCli.js} +10 -10
- package/dist/application/{ProcessEvidence.js → process/ProcessEvidence.js} +4 -4
- package/dist/artifacts/ArtifactProvider.js +30 -3
- package/dist/artifacts/ArtifactProviderMetadata.js +2 -1
- package/dist/artifacts/ZipArtifactReader.js +3 -0
- package/dist/artifacts/apple/DylibResolutionReader.js +259 -0
- package/dist/artifacts/apple/MachoLoadCommandReader.js +294 -0
- package/dist/{application → artifacts/extraction}/ArtifactExtraction.js +10 -10
- package/dist/{application → artifacts/inventory}/ArtifactGraphConstruction.js +3 -3
- package/dist/{application → artifacts/inventory}/ArtifactInventory.js +4 -4
- package/dist/{application/ArtifactInventory → artifacts/inventory}/classify.js +2 -2
- package/dist/{application/ArtifactInventory → artifacts/inventory}/reader.js +5 -5
- package/dist/{application/ArtifactInventory → artifacts/inventory}/scanCanonical.js +3 -3
- package/dist/{application/ArtifactInventory → artifacts/inventory}/scanReader.js +5 -5
- package/dist/artifacts/readStableArtifact.js +20 -4
- package/dist/browser/CdpCaptureEventHandlers.js +90 -2
- package/dist/browser/CdpCaptureEvents.js +9 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +12 -3
- package/dist/browser/history/CaptureFailures.js +101 -0
- package/dist/browser/history/CaptureFormatError.js +10 -0
- package/dist/browser/history/CaptureRedaction.js +65 -0
- package/dist/browser/history/CaptureRelease.js +12 -0
- package/dist/browser/history/HarCapture.js +165 -0
- package/dist/browser/history/HarCaptureAdapter.js +20 -0
- package/dist/browser/history/HarCaptureProcess.js +57 -0
- package/dist/browser/history/HarJson.js +91 -0
- package/dist/browser/history/HarSchema.js +72 -0
- package/dist/browser/history/HistoricalCaptureDecoder.js +186 -0
- package/dist/browser/history/HistoricalCaptureFormatAdapter.js +1 -0
- package/dist/browser/history/MitmproxyCaptureAdapter.js +42 -0
- package/dist/cli/artifactCommands.js +26 -1
- package/dist/cli/binaryDiagnosticsCommands.js +39 -0
- package/dist/cli/coreAnalysisCommands.js +2 -2
- package/dist/cli/coreBinaryCommands.js +8 -8
- package/dist/cli/electronCommands.js +16 -9
- package/dist/cli/evmCommands.js +24 -0
- package/dist/cli/firmwareCommands.js +6 -3
- package/dist/cli/javascriptApplicationAnalysis.js +16 -3
- package/dist/cli/jsonOutput.js +133 -0
- package/dist/cli/nativeCallCommands.js +35 -0
- package/dist/cli/processCommands.js +1 -1
- package/dist/cli/streamedJsonOutput.js +56 -0
- package/dist/cli/utilityCommands.js +2 -0
- package/dist/cli/webNetworkCaptureCommands.js +40 -0
- package/dist/cli.js +9 -3
- package/dist/cliBrowserScenarioCommands.js +2 -2
- package/dist/cliCommandNames.js +6 -0
- package/dist/cliJsonInput.js +30 -1
- package/dist/cliOutput.js +21 -6
- package/dist/composition/binaryDiagnostics.js +8 -0
- package/dist/composition/evm.js +4 -0
- package/dist/composition/webNetworkCaptures.js +6 -0
- package/dist/contracts/artifactToolContracts.js +6 -0
- package/dist/contracts/browserCaptureToolInputSchema.js +43 -0
- package/dist/contracts/browserToolContracts.js +4 -3
- package/dist/contracts/errorSchemas.js +8 -1
- package/dist/contracts/evm/evmToolContracts.js +20 -0
- package/dist/contracts/investigationExamples.js +2 -2
- package/dist/contracts/managed/managedToolContracts.js +7 -3
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +42 -0
- package/dist/contracts/native/nativeToolContracts.js +17 -1
- package/dist/contracts/officialToolContracts.js +12 -9
- package/dist/contracts/process/processCaptureExample.js +2 -0
- package/dist/contracts/sessionLifecycleInputs.js +22 -5
- package/dist/contracts/sessionStatusContract.js +10 -2
- package/dist/contracts/sessionToolContracts.js +8 -1
- package/dist/contracts/sessionToolSchemas.js +10 -3
- package/dist/contracts/toolContractExamples.js +1 -1
- package/dist/contracts/toolContracts.js +6 -0
- package/dist/contracts/toolEffects.js +30 -0
- package/dist/contracts/toolOutputSchemaGroups.js +5 -1
- package/dist/contracts/toolOutputSchemaPrimitives.js +1 -1
- package/dist/contracts/webNetworkCaptureToolContracts.js +24 -0
- package/dist/domain/analysisErrorBase.js +15 -0
- package/dist/domain/analysisErrorCore.js +59 -5
- package/dist/domain/analysisErrorPresentation.js +29 -1
- package/dist/domain/analysisErrorProjection.js +52 -2
- package/dist/domain/analysisSnapshot.js +166 -2
- package/dist/domain/apple/dyldPaths.js +81 -0
- package/dist/domain/apple/dylibResolution.js +367 -0
- package/dist/domain/apple/dylibResolutionFindings.js +75 -0
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/browserObservation.js +1 -1
- package/dist/domain/browserObservationSchemas.js +13 -0
- package/dist/domain/browserScenarioValues.js +9 -2
- package/dist/domain/callPathSchemas.js +1 -1
- package/dist/domain/canonicalDigest.js +13 -1
- package/dist/domain/changedBehavior.js +3 -3
- package/dist/domain/comparisonStatus.js +2 -30
- package/dist/domain/conformanceTrustGate.js +0 -16
- package/dist/domain/evidence.js +17 -5
- package/dist/domain/evm/evmInterface.js +63 -0
- package/dist/domain/explicitSensitiveFailure.js +92 -0
- package/dist/domain/explicitSensitiveValues.js +10 -0
- package/dist/domain/firmware/firmwareAnalysis.js +8 -1
- package/dist/domain/javascript/electronActiveObservation.js +9 -4
- package/dist/domain/javascript/htmlArtifactReferences.js +40 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +21 -5
- package/dist/domain/javascript/javascriptExportShapeVariants.js +0 -10
- package/dist/domain/javascript/javascriptSemanticGraph.js +21 -5
- package/dist/domain/jsonValue.js +4 -0
- package/dist/domain/localPath.js +2 -0
- package/dist/domain/native/binaryLayout.js +357 -0
- package/dist/domain/native/nativeCallObservation.js +164 -0
- package/dist/domain/native/objcSwiftMetadata.js +0 -39
- package/dist/domain/native/recordedCrash.js +266 -0
- package/dist/domain/native/recordedCrashNoteCoverage.js +73 -0
- package/dist/domain/{processCapture.js → process/processCapture.js} +139 -2
- package/dist/domain/{processCaptureExample.js → process/processCaptureExample.js} +5 -0
- package/dist/domain/process/processCaptureParsing.js +54 -0
- package/dist/domain/{processCaptureValidation.js → process/processCaptureValidation.js} +18 -2
- package/dist/domain/{processComparison.js → process/processComparison.js} +1 -1
- package/dist/domain/{processObservation.js → process/processObservation.js} +1 -1
- package/dist/domain/{processTraceSpecification.js → process/processTraceSpecification.js} +1 -1
- package/dist/domain/providerSelectionError.js +4 -2
- package/dist/domain/reconstructionVerification.js +3 -3
- package/dist/domain/reconstructionVerificationSchemas.js +1 -1
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +3 -3
- package/dist/domain/webCaptureDiff.js +1 -0
- package/dist/domain/webNetworkCapture.js +118 -0
- package/dist/domain/webNetworkCaptureCoordinates.js +58 -0
- package/dist/dotnet/ManagedExceptionRegionValidation.js +41 -0
- package/dist/dotnet/ManagedMemberInspector.js +4 -2
- package/dist/dotnet/ManagedMemberInspectorCore.js +38 -32
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +23 -7
- package/dist/dotnet/ManagedMemberRows.js +14 -3
- package/dist/dotnet/ManagedMetadataHeaps.js +20 -2
- package/dist/dotnet/ManagedMetadataInventory.js +38 -28
- package/dist/dotnet/ManagedMetadataInventoryRows.js +24 -10
- package/dist/dotnet/ManagedMethodBodyReader.js +7 -1
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +15 -3
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +3 -1
- package/dist/dotnet/ManagedPeReader.js +11 -0
- package/dist/evm/EvmBytecodeCarrier.js +21 -0
- package/dist/evm/EvmWorkerLimits.js +40 -0
- package/dist/evm/EvmoleFailures.js +126 -0
- package/dist/evm/EvmoleInterfaceAdapter.js +53 -0
- package/dist/evm/EvmoleInterfaceProvider.js +273 -0
- package/dist/evm/EvmoleInterfaceWorker.js +87 -0
- package/dist/evm/EvmoleRelease.js +16 -0
- package/dist/firmware/FirmwareCommand.js +1 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraLauncher.js +1 -0
- package/dist/ghidra/GhidraProvider.js +2 -2
- package/dist/ghidra/GhidraProviderCapabilities.js +1 -1
- package/dist/hopper/BridgeLauncher.js +2 -0
- package/dist/hopper/LinuxPrivateDisplayProbe.js +4 -2
- package/dist/javascript/recovery/WakaruCommand.js +3 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +1 -0
- package/dist/native/CommandRunner.js +2 -1
- package/dist/native/LldbCallTracer.js +278 -0
- package/dist/native/NativeCallObservation.js +135 -0
- package/dist/native/NativeMacOSProvider.js +19 -3
- package/dist/native/NativeMacOSProviderMetadata.js +8 -3
- package/dist/native/pwndbg/PwndbgCoreContext.js +160 -0
- package/dist/native/pwntools/PwntoolsDecoder.js +203 -0
- package/dist/native/pwntools/PwntoolsFailures.js +180 -0
- package/dist/native/pwntools/PwntoolsLayoutProvider.js +36 -0
- package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +75 -0
- package/dist/native/pwntools/PwntoolsRelease.js +19 -0
- package/dist/native/pwntools/PwntoolsResourceLimits.js +76 -0
- package/dist/native/pwntools/RecordedCrashSourceBindings.js +46 -0
- package/dist/native/pwntools/RecordedCrashStructureBindings.js +101 -0
- package/dist/process/DarwinProcessRunTokenReader.js +294 -0
- package/dist/process/OwnedCommand.js +113 -0
- package/dist/process/ProcessOwnership.js +263 -33
- package/dist/process/ProcessOwnershipObservation.js +161 -24
- package/dist/process/ProviderProcess.js +30 -3
- package/dist/{application → process/capture}/ProcessCaptureCapability.js +15 -0
- package/dist/{application → process/capture}/ProcessCaptureError.js +17 -1
- package/dist/process/capture/ProcessCaptureLifecycle.js +615 -0
- package/dist/{application → process/capture}/ProcessHarness.js +195 -29
- package/dist/{application → process/capture}/ProcessSampling.js +2 -2
- package/dist/server/createServer.js +22 -0
- package/dist/server/promptCompletion.js +10 -3
- package/dist/server/registerBinaryDiagnosticsTools.js +17 -0
- package/dist/server/registerEvidenceTools.js +1 -1
- package/dist/server/registerEvmTools.js +17 -0
- package/dist/server/registerProcessComparisonTool.js +1 -1
- package/dist/server/registerRecordedCrashTools.js +17 -0
- package/dist/server/registerSessionTools.js +2 -2
- package/dist/server/registerWebNetworkCaptureTool.js +28 -0
- package/dist/server/sessionAvailabilityPolicy.js +3 -0
- package/dist/server/sessionToolPolicies.js +1 -1
- package/dist/server/toolResult.js +1 -1
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +37 -9
- package/scripts/rea.mjs +11 -3
- package/skills/reverse-engineer-anything/SKILL.md +23 -3
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +29 -0
- package/third_party/README.md +60 -0
- package/third_party/evmole/LICENSE +21 -0
- package/third_party/evmole/README.md +22 -0
- package/third_party/pwndbg/LICENSE.md +21 -0
- package/third_party/pwndbg/README.md +23 -0
- package/third_party/pwntools/README.md +40 -0
- package/dist/application/AuthorizedArtifactInventory.js +0 -7
- package/dist/application/ProcessCaptureLifecycle.js +0 -299
- package/dist/application/StoreFileLock.js +0 -124
- package/dist/contracts/processCaptureExample.js +0 -2
- package/dist/domain/bytecodeProvider.js +0 -178
- package/dist/domain/customProtocolCapture.js +0 -137
- package/dist/domain/eventProcessTree.js +0 -225
- package/dist/domain/mobileApplicationInvestigation.js +0 -159
- package/dist/domain/packageAnalysis.js +0 -123
- package/dist/domain/peInspection.js +0 -197
- package/dist/domain/processCaptureParsing.js +0 -21
- package/dist/domain/protocolCapture.js +0 -217
- package/dist/domain/runtimeIdentification.js +0 -212
- package/dist/generatedMcpToolCatalog.js +0 -37
- /package/dist/application/{ArtifactExtractionDestination.js → artifacts/ArtifactExtractionDestination.js} +0 -0
- /package/dist/{application/ArtifactInventory → artifacts/inventory}/policy.js +0 -0
- /package/dist/{application/ArtifactInventory → artifacts/inventory}/types.js +0 -0
- /package/dist/domain/{processEvidenceProvider.js → process/processEvidenceProvider.js} +0 -0
- /package/dist/domain/{processScenario.js → process/processScenario.js} +0 -0
- /package/dist/domain/{processTraceComparison.js → process/processTraceComparison.js} +0 -0
- /package/dist/domain/{processTraceDimensionProjection.js → process/processTraceDimensionProjection.js} +0 -0
- /package/dist/domain/{processTraceEvaluation.js → process/processTraceEvaluation.js} +0 -0
- /package/dist/{application → process/capture}/FilesystemSnapshot.js +0 -0
- /package/dist/{application → process/capture}/ProcessCaptureEnvironment.js +0 -0
- /package/dist/{application → process/capture}/ProcessCaptureJournal.js +0 -0
- /package/dist/{application → process/capture}/ProcessFilesystemEffects.js +0 -0
- /package/dist/{application → process/capture}/ProcessNormalization.js +0 -0
- /package/dist/{application → process/capture}/ProcessScenarioRuntimeValidation.js +0 -0
- /package/dist/{application → process/capture}/ProcessTimer.js +0 -0
- /package/dist/{application → process/capture}/TerminalRenderer.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createJavaScriptSemanticGraphUnknown } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
2
|
-
import {
|
|
2
|
+
import { retainSemanticGraphNode, addSemanticGraphRelation, addSemanticGraphUnknown, } from "./JavaScriptSemanticGraphConstruction.js";
|
|
3
3
|
import { unknownSemanticEvidence } from "./JavaScriptSemanticGraphEvidence.js";
|
|
4
4
|
import { semanticCallSiteAt, } from "./JavaScriptSemanticGraphFlowProjection.js";
|
|
5
5
|
/** Project literal EventEmitter registrations, removals, and dispatches. */
|
|
@@ -34,7 +34,7 @@ export const projectSemanticEvents = (context) => {
|
|
|
34
34
|
addEventUnknown(context, operation, event, relation);
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
const addEventNode = (context, operation, eventKey) =>
|
|
37
|
+
const addEventNode = (context, operation, eventKey) => retainSemanticGraphNode(context.state, context.file, {
|
|
38
38
|
kind: "event",
|
|
39
39
|
roleKey: `event:${eventKey}`,
|
|
40
40
|
location: operation.eventName === null ? operation.location : null,
|
|
@@ -44,8 +44,8 @@ const addEventNode = (context, operation, eventKey) => addSemanticGraphNode(cont
|
|
|
44
44
|
emitter_key: operation.emitterKey,
|
|
45
45
|
event_name: operation.eventName,
|
|
46
46
|
},
|
|
47
|
-
}
|
|
48
|
-
const addListenerNode = (context, operation) =>
|
|
47
|
+
});
|
|
48
|
+
const addListenerNode = (context, operation) => retainSemanticGraphNode(context.state, context.file, {
|
|
49
49
|
kind: "listener",
|
|
50
50
|
roleKey: `listener:${operation.eventId}`,
|
|
51
51
|
location: operation.listenerLocation ?? operation.location,
|
|
@@ -61,7 +61,7 @@ const addListenerNode = (context, operation) => addSemanticGraphNode(context.sta
|
|
|
61
61
|
event_name: operation.eventName,
|
|
62
62
|
method: operation.method,
|
|
63
63
|
},
|
|
64
|
-
}
|
|
64
|
+
});
|
|
65
65
|
const eventEmitterNode = (context, operation) => (operation.emitterBindingId === null
|
|
66
66
|
? undefined
|
|
67
67
|
: context.bindingNodes.get(operation.emitterBindingId)) ??
|
|
@@ -95,7 +95,7 @@ export const projectSemanticTimers = (context) => {
|
|
|
95
95
|
const owner = operation.ownerCallableId === null
|
|
96
96
|
? undefined
|
|
97
97
|
: context.callableNodes.get(operation.ownerCallableId);
|
|
98
|
-
const timer =
|
|
98
|
+
const timer = retainSemanticGraphNode(context.state, context.file, {
|
|
99
99
|
kind: "timer",
|
|
100
100
|
roleKey: operation.timerId,
|
|
101
101
|
location: operation.location,
|
|
@@ -105,7 +105,7 @@ export const projectSemanticTimers = (context) => {
|
|
|
105
105
|
delay_milliseconds: operation.delayMilliseconds,
|
|
106
106
|
method: operation.method,
|
|
107
107
|
},
|
|
108
|
-
}
|
|
108
|
+
});
|
|
109
109
|
return timer === null ? [] : [[operation.timerId, timer]];
|
|
110
110
|
}));
|
|
111
111
|
for (const operation of context.ir.timerOperations)
|
|
@@ -10,73 +10,141 @@ import { projectSemanticValues } from "./JavaScriptSemanticGraphValueProjection.
|
|
|
10
10
|
import { inferredSemanticEvidenceAt } from "./JavaScriptSemanticGraphEvidence.js";
|
|
11
11
|
import { projectSemanticFunctionFingerprints } from "./JavaScriptSemanticGraphFingerprintProjection.js";
|
|
12
12
|
import { projectSemanticClosureCaptures, projectSemanticFrontiers, projectSemanticPromises, projectSemanticReturnValues, } from "./JavaScriptSemanticGraphFlowProjection.js";
|
|
13
|
-
import {
|
|
14
|
-
import { addSemanticFallbackRoot as addFallbackRoot,
|
|
15
|
-
/**
|
|
13
|
+
import { createSemanticCallableOwnerLookup, createSemanticCallSiteLookup, createSemanticNodeRangeLookup, semanticFamilyStatus, } from "./JavaScriptSemanticGraphProjection.js";
|
|
14
|
+
import { addSemanticFallbackRoot as addFallbackRoot, retainSemanticGraphNode as retainNode, addSemanticGraphRelation as addRelation, createSemanticGraphProjectionState as emptyState, bindSemanticGraphApplicationNodes, } from "./JavaScriptSemanticGraphConstruction.js";
|
|
15
|
+
/**
|
|
16
|
+
* Resource-safety ceiling on retained semantic nodes.
|
|
17
|
+
*
|
|
18
|
+
* The semantic projection emits one node per AST expression, call site, binding
|
|
19
|
+
* and property slot. That is unbounded in input size. A small tree of five files
|
|
20
|
+
* already yields on the order of 170,000 nodes, and larger trees yield millions,
|
|
21
|
+
* exhausting the heap before the result can be serialized.
|
|
22
|
+
*
|
|
23
|
+
* This is a real resource-safety constraint, not a presentation preference, so
|
|
24
|
+
* the ceiling is applied and reported through the graph's own `coverage` fields
|
|
25
|
+
* (`truncated`, `omitted_nodes`, `omitted_relations`, `limits`) rather than
|
|
26
|
+
* silently dropping data.
|
|
27
|
+
*
|
|
28
|
+
* Sizing: a retained semantic node costs roughly 3 KB once serialized, and V8
|
|
29
|
+
* additionally caps a single string at 512 MB. The result is serialized after the
|
|
30
|
+
* object graph is built and validated, so both phases must fit together. A single
|
|
31
|
+
* minified vendor bundle can account for most of a tree's nodes, so a whole-tree
|
|
32
|
+
* ceiling without a per-file ceiling does not bound the work. Both are applied.
|
|
33
|
+
*/
|
|
34
|
+
export const SEMANTIC_GRAPH_NODE_CEILING = 100_000;
|
|
35
|
+
/**
|
|
36
|
+
* Per-file share of the semantic node budget.
|
|
37
|
+
*
|
|
38
|
+
* Bound each source file independently so one large bundled library cannot
|
|
39
|
+
* consume the whole tree's budget and starve the application's own modules.
|
|
40
|
+
*/
|
|
41
|
+
export const SEMANTIC_GRAPH_FILE_NODE_CEILING = 20_000;
|
|
16
42
|
export const buildJavaScriptSemanticGraph = ({ rootArtifactSha256, applicationGraph, analysis, }) => {
|
|
17
|
-
const
|
|
18
|
-
const fingerprints = [];
|
|
43
|
+
const projection = createJavaScriptSemanticGraphProjection();
|
|
19
44
|
for (const analyzed of analysis.files) {
|
|
20
|
-
if (analyzed.semantic
|
|
21
|
-
|
|
22
|
-
fingerprints.push(...projectFile(analyzed.file, analyzed.semantic.ir, state));
|
|
45
|
+
if (analyzed.semantic !== null)
|
|
46
|
+
projection.projectFile(analyzed.file, analyzed.semantic.ir);
|
|
23
47
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
return projection.finish(rootArtifactSha256, applicationGraph, analysis);
|
|
49
|
+
};
|
|
50
|
+
/** Accumulate semantic nodes while each source IR is still file-local. */
|
|
51
|
+
export const createJavaScriptSemanticGraphProjection = () => {
|
|
52
|
+
const state = emptyState({ nodes: [] });
|
|
53
|
+
const fingerprints = [];
|
|
54
|
+
let truncatedFiles = 0;
|
|
55
|
+
const projectSource = (file, ir) => {
|
|
56
|
+
if (state.nodes.size >= SEMANTIC_GRAPH_NODE_CEILING) {
|
|
57
|
+
truncatedFiles += 1;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const remainingTreeBudget = SEMANTIC_GRAPH_NODE_CEILING - state.nodes.size;
|
|
61
|
+
state.fileNodeBudget = Math.min(SEMANTIC_GRAPH_FILE_NODE_CEILING, remainingTreeBudget);
|
|
62
|
+
state.fileNodesDropped = false;
|
|
63
|
+
fingerprints.push(...projectFile(file, ir, state));
|
|
64
|
+
// Nodes were dropped only if the budget actually blocked creation. A file
|
|
65
|
+
// that exactly fills its share ends with a zero budget without dropping
|
|
66
|
+
// anything, so the remaining budget alone cannot decide truncation.
|
|
67
|
+
if (state.fileNodesDropped)
|
|
68
|
+
truncatedFiles += 1;
|
|
69
|
+
state.fileNodeBudget = null;
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
projectFile: projectSource,
|
|
73
|
+
finish: (rootArtifactSha256, applicationGraph, analysis) => {
|
|
74
|
+
bindSemanticGraphApplicationNodes(state, applicationGraph);
|
|
75
|
+
if (state.roots.size === 0)
|
|
76
|
+
addFallbackRoot(rootArtifactSha256, state);
|
|
77
|
+
const unknowns = [...state.unknowns.values()];
|
|
78
|
+
const graph = createJavaScriptSemanticGraph({
|
|
79
|
+
schema: "JavaScriptSemanticRelationGraph",
|
|
80
|
+
root_artifact_sha256: rootArtifactSha256,
|
|
81
|
+
application_graph_id: applicationGraph.graph_id,
|
|
82
|
+
root_node_ids: [...state.roots],
|
|
83
|
+
nodes: [...state.nodes.values()],
|
|
84
|
+
relations: [...state.relations.values()],
|
|
85
|
+
fingerprints,
|
|
86
|
+
unknowns,
|
|
87
|
+
coverage: {
|
|
88
|
+
status: truncatedFiles > 0 ? "partial" : "unknown",
|
|
89
|
+
truncated: truncatedFiles > 0,
|
|
90
|
+
omitted_nodes: truncatedFiles > 0 ? null : 0,
|
|
91
|
+
omitted_relations: truncatedFiles > 0 ? null : 0,
|
|
92
|
+
limits: truncatedFiles > 0
|
|
93
|
+
? [
|
|
94
|
+
{
|
|
95
|
+
name: "semantic_graph_node_ceiling",
|
|
96
|
+
value: SEMANTIC_GRAPH_NODE_CEILING,
|
|
97
|
+
unit: "items",
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
: [],
|
|
101
|
+
families: JAVASCRIPT_SEMANTIC_RELATION_FAMILIES.map((family) => ({
|
|
102
|
+
family,
|
|
103
|
+
status: semanticFamilyStatus(family, analysis),
|
|
104
|
+
retained_relations: [...state.relations.values()].filter((relation) => JAVASCRIPT_SEMANTIC_RELATION_FAMILY[relation.relation] ===
|
|
105
|
+
family).length,
|
|
106
|
+
omitted_relations: truncatedFiles > 0 ? null : 0,
|
|
107
|
+
unknown_ids: unknowns
|
|
108
|
+
.filter((unknown) => unknown.family === family)
|
|
109
|
+
.map(({ unknown_id: identifier }) => identifier),
|
|
110
|
+
})),
|
|
111
|
+
},
|
|
112
|
+
limitations: [
|
|
113
|
+
"The semantic graph contains static syntax observations and conservative relationship candidates; it does not claim runtime execution.",
|
|
114
|
+
"Local data flow does not claim control-flow-sensitive reaching definitions or arbitrary dynamic property resolution.",
|
|
115
|
+
"Promise ownership covers explicit unshadowed Promise construction, static factories, aggregation, chaining, and await syntax only.",
|
|
116
|
+
"Function fingerprints are static candidates; equal digests can remain ambiguous and do not prove behavioral equivalence.",
|
|
117
|
+
"Event extraction covers EventEmitter-style literal registrations, removals, and dispatch candidates; dynamic names remain unknown.",
|
|
118
|
+
"Timer extraction covers global or node:timers scheduling and exact local-handle cancellation.",
|
|
119
|
+
"Child-process extraction covers asynchronous node:child_process creation, literal argv/env/stdio options, exit/error listeners, and kill signals.",
|
|
120
|
+
"Configuration extraction covers process.env, process.argv, node:fs reads, and direct logical defaults.",
|
|
121
|
+
"Request extraction covers fetch, WebSocket, node:http/node:https construction, direct option fields, and exact local response consumers.",
|
|
122
|
+
"Boundary extraction covers unshadowed JSON/global coercions plus parse and validation method candidates.",
|
|
123
|
+
"Resource extraction covers built-in filesystem/network acquisition and exact local close/destroy/end handles.",
|
|
124
|
+
],
|
|
125
|
+
});
|
|
126
|
+
state.nodes.clear();
|
|
127
|
+
state.relations.clear();
|
|
128
|
+
state.unknowns.clear();
|
|
129
|
+
state.roots.clear();
|
|
130
|
+
fingerprints.length = 0;
|
|
131
|
+
return graph;
|
|
51
132
|
},
|
|
52
|
-
|
|
53
|
-
"The semantic graph contains static syntax observations and conservative relationship candidates; it does not claim runtime execution.",
|
|
54
|
-
"Local data flow does not claim control-flow-sensitive reaching definitions or arbitrary dynamic property resolution.",
|
|
55
|
-
"Promise ownership covers explicit unshadowed Promise construction, static factories, aggregation, chaining, and await syntax only.",
|
|
56
|
-
"Function fingerprints are static candidates; equal digests can remain ambiguous and do not prove behavioral equivalence.",
|
|
57
|
-
"Event extraction covers EventEmitter-style literal registrations, removals, and dispatch candidates; dynamic names remain unknown.",
|
|
58
|
-
"Timer extraction covers global or node:timers scheduling and exact local-handle cancellation.",
|
|
59
|
-
"Child-process extraction covers asynchronous node:child_process creation, literal argv/env/stdio options, exit/error listeners, and kill signals.",
|
|
60
|
-
"Configuration extraction covers process.env, process.argv, node:fs reads, and direct logical defaults.",
|
|
61
|
-
"Request extraction covers fetch, WebSocket, node:http/node:https construction, direct option fields, and exact local response consumers.",
|
|
62
|
-
"Boundary extraction covers unshadowed JSON/global coercions plus parse and validation method candidates.",
|
|
63
|
-
"Resource extraction covers built-in filesystem/network acquisition and exact local close/destroy/end handles.",
|
|
64
|
-
],
|
|
65
|
-
});
|
|
133
|
+
};
|
|
66
134
|
};
|
|
67
135
|
const projectFile = (file, ir, state) => {
|
|
68
|
-
const moduleNode =
|
|
136
|
+
const moduleNode = retainNode(state, file, {
|
|
69
137
|
kind: "module",
|
|
70
138
|
roleKey: "module",
|
|
71
139
|
location: null,
|
|
72
140
|
label: file.path,
|
|
73
141
|
functionNodeId: null,
|
|
74
|
-
}
|
|
142
|
+
});
|
|
75
143
|
if (moduleNode === null)
|
|
76
144
|
return [];
|
|
77
145
|
state.roots.add(moduleNode.node_id);
|
|
78
146
|
const callableNodes = new Map(ir.callables.flatMap((callable) => {
|
|
79
|
-
const node =
|
|
147
|
+
const node = retainNode(state, file, {
|
|
80
148
|
kind: "function",
|
|
81
149
|
roleKey: `callable:${callable.callableId}`,
|
|
82
150
|
location: callable.location,
|
|
@@ -84,25 +152,26 @@ const projectFile = (file, ir, state) => {
|
|
|
84
152
|
functionNodeId: null,
|
|
85
153
|
// The label is display text; keep the exact name, which may be "".
|
|
86
154
|
properties: { name: callable.name },
|
|
87
|
-
}
|
|
155
|
+
});
|
|
88
156
|
return node === null ? [] : [[callable.callableId, node]];
|
|
89
157
|
}));
|
|
158
|
+
const callableOwnerAt = createSemanticCallableOwnerLookup(ir, callableNodes);
|
|
90
159
|
const bindingNodes = new Map(ir.bindings.flatMap((binding) => {
|
|
91
160
|
const location = binding.definitions[0]?.location ?? null;
|
|
92
161
|
const kind = binding.kind === "parameter" ? "parameter" : "binding";
|
|
93
|
-
const owner =
|
|
94
|
-
const node =
|
|
162
|
+
const owner = callableOwnerAt(location);
|
|
163
|
+
const node = retainNode(state, file, {
|
|
95
164
|
kind,
|
|
96
165
|
roleKey: `binding:${binding.bindingId}`,
|
|
97
166
|
location,
|
|
98
167
|
label: binding.name,
|
|
99
168
|
functionNodeId: owner?.node_id ?? null,
|
|
100
|
-
}
|
|
169
|
+
});
|
|
101
170
|
return node === null ? [] : [[binding.bindingId, node]];
|
|
102
171
|
}));
|
|
103
172
|
const returnSiteNodes = createReturnSiteNodes(file, ir, callableNodes, state);
|
|
104
173
|
const callSiteNodes = createCallSiteNodes(file, ir, callableNodes, state);
|
|
105
|
-
const
|
|
174
|
+
const definitions = {
|
|
106
175
|
file,
|
|
107
176
|
ir,
|
|
108
177
|
state,
|
|
@@ -117,8 +186,14 @@ const projectFile = (file, ir, state) => {
|
|
|
117
186
|
call.callSiteId,
|
|
118
187
|
call.resolution === "exact" ? "resolved" : "candidate",
|
|
119
188
|
])),
|
|
189
|
+
callableOwnerAt,
|
|
190
|
+
callSiteAt: createSemanticCallSiteLookup(ir, callSiteNodes),
|
|
191
|
+
};
|
|
192
|
+
projectDefinitionsAndReferences(definitions);
|
|
193
|
+
const context = {
|
|
194
|
+
...definitions,
|
|
195
|
+
referenceNodesWithin: createSemanticNodeRangeLookup(definitions.referenceNodes),
|
|
120
196
|
};
|
|
121
|
-
projectDefinitionsAndReferences(context);
|
|
122
197
|
projectSemanticValues(context);
|
|
123
198
|
projectSemanticObjects(context);
|
|
124
199
|
projectCalls(context);
|
|
@@ -142,13 +217,13 @@ const createReturnSiteNodes = (file, ir, callables, state) => {
|
|
|
142
217
|
continue;
|
|
143
218
|
for (const site of callable.returnSites) {
|
|
144
219
|
const identifier = site.returnSiteId;
|
|
145
|
-
const node =
|
|
220
|
+
const node = retainNode(state, file, {
|
|
146
221
|
kind: "return-site",
|
|
147
222
|
roleKey: identifier,
|
|
148
223
|
location: site.location,
|
|
149
224
|
label: "return",
|
|
150
225
|
functionNodeId: owner.node_id,
|
|
151
|
-
}
|
|
226
|
+
});
|
|
152
227
|
if (node !== null)
|
|
153
228
|
result.set(identifier, node);
|
|
154
229
|
}
|
|
@@ -161,13 +236,13 @@ const createCallSiteNodes = (file, ir, callables, state) => {
|
|
|
161
236
|
const owner = call.callerCallableId === null
|
|
162
237
|
? null
|
|
163
238
|
: (callables.get(call.callerCallableId)?.node_id ?? null);
|
|
164
|
-
const node =
|
|
239
|
+
const node = retainNode(state, file, {
|
|
165
240
|
kind: "call-site",
|
|
166
241
|
roleKey: `call:${call.callSiteId}`,
|
|
167
242
|
location: call.location,
|
|
168
243
|
label: call.kind,
|
|
169
244
|
functionNodeId: owner,
|
|
170
|
-
}
|
|
245
|
+
});
|
|
171
246
|
if (node !== null)
|
|
172
247
|
result.set(call.callSiteId, node);
|
|
173
248
|
}
|
|
@@ -179,13 +254,13 @@ const projectDefinitionsAndReferences = (context) => {
|
|
|
179
254
|
if (bindingNode === undefined)
|
|
180
255
|
continue;
|
|
181
256
|
for (const [index, definition] of binding.definitions.entries()) {
|
|
182
|
-
const definitionNode =
|
|
257
|
+
const definitionNode = retainNode(context.state, context.file, {
|
|
183
258
|
kind: "expression",
|
|
184
259
|
roleKey: `definition:${binding.bindingId}:${String(index)}`,
|
|
185
260
|
location: definition.location,
|
|
186
261
|
label: definition.kind,
|
|
187
262
|
functionNodeId: bindingNode.function_node_id,
|
|
188
|
-
}
|
|
263
|
+
});
|
|
189
264
|
addRelation(context.state, {
|
|
190
265
|
source: definitionNode,
|
|
191
266
|
target: bindingNode,
|
|
@@ -195,13 +270,13 @@ const projectDefinitionsAndReferences = (context) => {
|
|
|
195
270
|
}
|
|
196
271
|
}
|
|
197
272
|
for (const [index, reference] of context.ir.references.entries()) {
|
|
198
|
-
const expression =
|
|
273
|
+
const expression = retainNode(context.state, context.file, {
|
|
199
274
|
kind: "expression",
|
|
200
275
|
roleKey: `reference:${String(index)}:${reference.role}:${reference.name}`,
|
|
201
276
|
location: reference.location,
|
|
202
277
|
label: reference.name,
|
|
203
|
-
functionNodeId:
|
|
204
|
-
}
|
|
278
|
+
functionNodeId: context.callableOwnerAt(reference.location)?.node_id ?? null,
|
|
279
|
+
});
|
|
205
280
|
const binding = reference.bindingId === null
|
|
206
281
|
? undefined
|
|
207
282
|
: context.bindingNodes.get(reference.bindingId);
|
|
@@ -244,7 +319,7 @@ const projectCalls = (context) => {
|
|
|
244
319
|
const argumentNode = createArgumentNode(context, callNode, call.callSiteId, argument);
|
|
245
320
|
if (argumentNode !== null)
|
|
246
321
|
context.argumentNodes.set(`${call.callSiteId}\u0000${String(argument.index)}`, argumentNode);
|
|
247
|
-
const references =
|
|
322
|
+
const references = context.referenceNodesWithin(argument.location);
|
|
248
323
|
for (const reference of references)
|
|
249
324
|
addRelation(context.state, {
|
|
250
325
|
source: reference,
|
|
@@ -283,7 +358,7 @@ const projectCalls = (context) => {
|
|
|
283
358
|
});
|
|
284
359
|
projectSemanticReturnValues(context);
|
|
285
360
|
};
|
|
286
|
-
const createArgumentNode = (context, callNode, callSiteId, argument) =>
|
|
361
|
+
const createArgumentNode = (context, callNode, callSiteId, argument) => retainNode(context.state, context.file, {
|
|
287
362
|
kind: "expression",
|
|
288
363
|
roleKey: `argument:${callSiteId}:${String(argument.index)}`,
|
|
289
364
|
location: argument.location,
|
|
@@ -291,4 +366,4 @@ const createArgumentNode = (context, callNode, callSiteId, argument) => addNode(
|
|
|
291
366
|
? "spread argument"
|
|
292
367
|
: `argument ${String(argument.index)}`,
|
|
293
368
|
functionNodeId: callNode.function_node_id,
|
|
294
|
-
}
|
|
369
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createJavaScriptSemanticGraphUnknown } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
2
|
-
import {
|
|
2
|
+
import { retainSemanticGraphNode, addSemanticGraphRelation, addSemanticGraphUnknown, } from "./JavaScriptSemanticGraphConstruction.js";
|
|
3
3
|
import { unknownSemanticEvidence } from "./JavaScriptSemanticGraphEvidence.js";
|
|
4
4
|
import { semanticCallSiteAt, } from "./JavaScriptSemanticGraphFlowProjection.js";
|
|
5
5
|
/** Project child creation, argv/env/stdio, listeners, and signals. */
|
|
@@ -17,15 +17,14 @@ export const projectSemanticChildProcesses = (context) => {
|
|
|
17
17
|
for (const interaction of context.ir.childProcessInteractions)
|
|
18
18
|
projectInteraction(context, interaction, processNodes);
|
|
19
19
|
};
|
|
20
|
-
const addChildProcessNode = (context, spawn) =>
|
|
20
|
+
const addChildProcessNode = (context, spawn) => retainSemanticGraphNode(context.state, context.file, {
|
|
21
21
|
kind: "child-process",
|
|
22
22
|
roleKey: spawn.processId,
|
|
23
23
|
location: spawn.location,
|
|
24
24
|
label: spawn.command ?? spawn.method,
|
|
25
25
|
functionNodeId: spawn.ownerCallableId === null
|
|
26
26
|
? null
|
|
27
|
-
: (context.callableNodes.get(spawn.ownerCallableId)?.node_id ??
|
|
28
|
-
null),
|
|
27
|
+
: (context.callableNodes.get(spawn.ownerCallableId)?.node_id ?? null),
|
|
29
28
|
properties: {
|
|
30
29
|
argv_count: spawn.argvCount,
|
|
31
30
|
command: spawn.command,
|
|
@@ -33,7 +32,7 @@ const addChildProcessNode = (context, spawn) => addSemanticGraphNode(context.sta
|
|
|
33
32
|
method: spawn.method,
|
|
34
33
|
stdio_mode: spawn.stdioMode,
|
|
35
34
|
},
|
|
36
|
-
}
|
|
35
|
+
});
|
|
37
36
|
const projectSpawn = (context, spawn, child) => {
|
|
38
37
|
const callSite = semanticCallSiteAt(context, spawn.location);
|
|
39
38
|
addSemanticGraphRelation(context.state, {
|
|
@@ -85,14 +84,14 @@ const projectSpawn = (context, spawn, child) => {
|
|
|
85
84
|
candidateNodeIds: [],
|
|
86
85
|
});
|
|
87
86
|
};
|
|
88
|
-
const addStdioNode = (context, spawn, child) =>
|
|
87
|
+
const addStdioNode = (context, spawn, child) => retainSemanticGraphNode(context.state, context.file, {
|
|
89
88
|
kind: "stdio",
|
|
90
89
|
roleKey: `stdio:${spawn.processId}`,
|
|
91
90
|
location: spawn.location,
|
|
92
91
|
label: spawn.stdioMode,
|
|
93
92
|
functionNodeId: child.function_node_id,
|
|
94
93
|
properties: { mode: spawn.stdioMode },
|
|
95
|
-
}
|
|
94
|
+
});
|
|
96
95
|
const projectInteraction = (context, interaction, processNodes) => {
|
|
97
96
|
const children = interaction.linkedProcessIds.flatMap((identifier) => {
|
|
98
97
|
const child = processNodes.get(identifier);
|
|
@@ -128,31 +127,31 @@ const projectInteraction = (context, interaction, processNodes) => {
|
|
|
128
127
|
candidateNodeIds: children.map(({ node_id: identifier }) => identifier),
|
|
129
128
|
});
|
|
130
129
|
};
|
|
131
|
-
const addChildListenerNode = (context, interaction) =>
|
|
130
|
+
const addChildListenerNode = (context, interaction) => retainSemanticGraphNode(context.state, context.file, {
|
|
132
131
|
kind: "listener",
|
|
133
132
|
roleKey: interaction.interactionId,
|
|
134
133
|
location: interaction.listenerLocation ?? interaction.location,
|
|
135
134
|
label: interaction.eventName,
|
|
136
135
|
functionNodeId: interaction.ownerCallableId === null
|
|
137
136
|
? null
|
|
138
|
-
: (context.callableNodes.get(interaction.ownerCallableId)
|
|
139
|
-
|
|
137
|
+
: (context.callableNodes.get(interaction.ownerCallableId)?.node_id ??
|
|
138
|
+
null),
|
|
140
139
|
properties: {
|
|
141
140
|
event_name: interaction.eventName,
|
|
142
141
|
method: interaction.method,
|
|
143
142
|
},
|
|
144
|
-
}
|
|
145
|
-
const addSignalNode = (context, interaction) =>
|
|
143
|
+
});
|
|
144
|
+
const addSignalNode = (context, interaction) => retainSemanticGraphNode(context.state, context.file, {
|
|
146
145
|
kind: "signal",
|
|
147
146
|
roleKey: interaction.interactionId,
|
|
148
147
|
location: interaction.location,
|
|
149
148
|
label: interaction.signalName,
|
|
150
149
|
functionNodeId: interaction.ownerCallableId === null
|
|
151
150
|
? null
|
|
152
|
-
: (context.callableNodes.get(interaction.ownerCallableId)
|
|
153
|
-
|
|
151
|
+
: (context.callableNodes.get(interaction.ownerCallableId)?.node_id ??
|
|
152
|
+
null),
|
|
154
153
|
properties: { signal_name: interaction.signalName },
|
|
155
|
-
}
|
|
154
|
+
});
|
|
156
155
|
const addChildUnknown = (input) => {
|
|
157
156
|
const { context, node, location, relationKinds, detail, candidateNodeIds } = input;
|
|
158
157
|
addSemanticGraphUnknown(context.state, createJavaScriptSemanticGraphUnknown({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { javascriptDisplayText } from "../../domain/javascript/javascriptAstValues.js";
|
|
2
|
-
import { createJavaScriptSemanticGraphNode, createJavaScriptSemanticGraphRelation, } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
2
|
+
import { createJavaScriptSemanticGraphNode, createJavaScriptSemanticGraphRelation, javaScriptSemanticNodeId, } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
3
3
|
import { inferredSemanticEvidence, observedSemanticEvidence, unavailableSemanticRootEvidence, } from "./JavaScriptSemanticGraphEvidence.js";
|
|
4
4
|
/** Create empty projection state with structural application-node mappings. */
|
|
5
5
|
export const createSemanticGraphProjectionState = (applicationGraph) => {
|
|
@@ -12,6 +12,18 @@ export const createSemanticGraphProjectionState = (applicationGraph) => {
|
|
|
12
12
|
applicationNodeIdsByLocation: index.identifiers,
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
+
/** Bind retained semantic identities after all application observations exist. */
|
|
16
|
+
export const bindSemanticGraphApplicationNodes = (state, applicationGraph) => {
|
|
17
|
+
const index = indexApplicationNodes(applicationGraph.nodes).identifiers;
|
|
18
|
+
for (const [identifier, node] of state.nodes) {
|
|
19
|
+
state.nodes.set(identifier, {
|
|
20
|
+
...node,
|
|
21
|
+
application_node_ids: [
|
|
22
|
+
...(index.get(applicationLocationKey(node.identity.artifact_sha256, node.identity.module_path, node.identity.source_range)) ?? []),
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
15
27
|
/** Construct one canonical semantic node backed by an exact artifact file. */
|
|
16
28
|
export const constructSemanticGraphNode = (file, input, state) => createJavaScriptSemanticGraphNode({
|
|
17
29
|
kind: input.kind,
|
|
@@ -27,11 +39,39 @@ export const constructSemanticGraphNode = (file, input, state) => createJavaScri
|
|
|
27
39
|
properties: input.properties ?? {},
|
|
28
40
|
evidence: observedSemanticEvidence(file, input.location),
|
|
29
41
|
});
|
|
42
|
+
/** Reuse retained identities and reject exhausted budgets before allocation. */
|
|
43
|
+
export const retainSemanticGraphNode = (state, file, input) => {
|
|
44
|
+
const identifier = javaScriptSemanticNodeId({
|
|
45
|
+
kind: input.kind,
|
|
46
|
+
identity: {
|
|
47
|
+
artifact_sha256: file.sha256,
|
|
48
|
+
module_path: file.path,
|
|
49
|
+
source_range: input.location,
|
|
50
|
+
role_key: input.roleKey,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
const existing = state.nodes.get(identifier);
|
|
54
|
+
if (existing !== undefined)
|
|
55
|
+
return existing;
|
|
56
|
+
if (typeof state.fileNodeBudget === "number" && state.fileNodeBudget <= 0) {
|
|
57
|
+
state.fileNodesDropped = true;
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return addSemanticGraphNode(state, constructSemanticGraphNode(file, input, state));
|
|
61
|
+
};
|
|
30
62
|
/** Retain one canonical semantic node. */
|
|
31
63
|
export const addSemanticGraphNode = (state, node) => {
|
|
32
64
|
const existing = state.nodes.get(node.node_id);
|
|
33
65
|
if (existing !== undefined)
|
|
34
66
|
return existing;
|
|
67
|
+
const budget = state.fileNodeBudget;
|
|
68
|
+
if (typeof budget === "number") {
|
|
69
|
+
if (budget <= 0) {
|
|
70
|
+
state.fileNodesDropped = true;
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
state.fileNodeBudget = budget - 1;
|
|
74
|
+
}
|
|
35
75
|
state.nodes.set(node.node_id, node);
|
|
36
76
|
return node;
|
|
37
77
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createJavaScriptSemanticGraphUnknown } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
2
|
-
import {
|
|
2
|
+
import { retainSemanticGraphNode, addSemanticGraphRelation, addSemanticGraphUnknown, } from "./JavaScriptSemanticGraphConstruction.js";
|
|
3
3
|
import { unknownSemanticEvidence } from "./JavaScriptSemanticGraphEvidence.js";
|
|
4
4
|
import { semanticCallSiteAt, } from "./JavaScriptSemanticGraphFlowProjection.js";
|
|
5
5
|
/** Project environment, argv, file, default, and precedence candidates. */
|
|
@@ -41,7 +41,7 @@ export const projectSemanticConfiguration = (context) => {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
const addConfigurationNode = (context, operation) =>
|
|
44
|
+
const addConfigurationNode = (context, operation) => retainSemanticGraphNode(context.state, context.file, {
|
|
45
45
|
kind: "config-source",
|
|
46
46
|
roleKey: operation.configId,
|
|
47
47
|
location: operation.location,
|
|
@@ -55,7 +55,7 @@ const addConfigurationNode = (context, operation) => addSemanticGraphNode(contex
|
|
|
55
55
|
source_kind: operation.kind,
|
|
56
56
|
value: operation.value,
|
|
57
57
|
},
|
|
58
|
-
}
|
|
58
|
+
});
|
|
59
59
|
const configurationRelation = (operation) => operation.kind === "environment"
|
|
60
60
|
? "reads-environment"
|
|
61
61
|
: operation.kind === "argv"
|
|
@@ -94,7 +94,7 @@ export const projectSemanticRequests = (context) => {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
const addRequestNode = (context, operation) =>
|
|
97
|
+
const addRequestNode = (context, operation) => retainSemanticGraphNode(context.state, context.file, {
|
|
98
98
|
kind: operation.kind === "request" ? "request" : "response",
|
|
99
99
|
roleKey: operation.requestId,
|
|
100
100
|
location: operation.location,
|
|
@@ -108,7 +108,7 @@ const addRequestNode = (context, operation) => addSemanticGraphNode(context.stat
|
|
|
108
108
|
method: operation.method,
|
|
109
109
|
operation_kind: operation.kind,
|
|
110
110
|
},
|
|
111
|
-
}
|
|
111
|
+
});
|
|
112
112
|
const projectRequestConstruction = (context, operation, request) => {
|
|
113
113
|
const callSite = semanticCallSiteAt(context, operation.location);
|
|
114
114
|
addSemanticGraphRelation(context.state, {
|
|
@@ -182,7 +182,7 @@ export const projectSemanticBoundaries = (context) => {
|
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
const addBoundaryNode = (context, operation) =>
|
|
185
|
+
const addBoundaryNode = (context, operation) => retainSemanticGraphNode(context.state, context.file, {
|
|
186
186
|
kind: "boundary",
|
|
187
187
|
roleKey: operation.boundaryId,
|
|
188
188
|
location: operation.location,
|
|
@@ -195,7 +195,7 @@ const addBoundaryNode = (context, operation) => addSemanticGraphNode(context.sta
|
|
|
195
195
|
boundary_kind: operation.kind,
|
|
196
196
|
method: operation.method,
|
|
197
197
|
},
|
|
198
|
-
}
|
|
198
|
+
});
|
|
199
199
|
const bindingOrOwner = (context, bindingId, callableId) => (bindingId === null ? undefined : context.bindingNodes.get(bindingId)) ??
|
|
200
200
|
(callableId === null
|
|
201
201
|
? context.moduleNode
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { createJavaScriptSemanticGraphUnknown } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
2
2
|
import { sourceRangesEqual } from "../../domain/javascript/javascriptStaticAnalysisHelpers.js";
|
|
3
|
-
import {
|
|
3
|
+
import { retainSemanticGraphNode, addSemanticGraphRelation, addSemanticGraphUnknown, } from "./JavaScriptSemanticGraphConstruction.js";
|
|
4
4
|
import { inferredSemanticEvidenceAt, unknownSemanticEvidence, } from "./JavaScriptSemanticGraphEvidence.js";
|
|
5
|
-
import { semanticNodesWithinRange } from "./JavaScriptSemanticGraphProjection.js";
|
|
6
5
|
/** Find the retained call-site node at one exact semantic source range. */
|
|
7
6
|
export const semanticCallSiteAt = (context, location) => {
|
|
8
|
-
|
|
9
|
-
return call === undefined
|
|
10
|
-
? undefined
|
|
11
|
-
: context.callSiteNodes.get(call.callSiteId);
|
|
7
|
+
return context.callSiteAt(location);
|
|
12
8
|
};
|
|
13
9
|
/** Project explicit static Promise/task ownership without runtime claims. */
|
|
14
10
|
export const projectSemanticPromises = (context) => {
|
|
@@ -16,7 +12,7 @@ export const projectSemanticPromises = (context) => {
|
|
|
16
12
|
const owner = operation.ownerCallableId === null
|
|
17
13
|
? undefined
|
|
18
14
|
: context.callableNodes.get(operation.ownerCallableId);
|
|
19
|
-
const node =
|
|
15
|
+
const node = retainSemanticGraphNode(context.state, context.file, {
|
|
20
16
|
kind: operation.kind === "awaited-expression" ? "task" : "promise",
|
|
21
17
|
roleKey: operation.promiseId,
|
|
22
18
|
location: operation.location,
|
|
@@ -28,7 +24,7 @@ export const projectSemanticPromises = (context) => {
|
|
|
28
24
|
ownership: operation.ownership,
|
|
29
25
|
source_resolution: operation.sourceResolution,
|
|
30
26
|
},
|
|
31
|
-
}
|
|
27
|
+
});
|
|
32
28
|
return node === null ? [] : [[operation.promiseId, node]];
|
|
33
29
|
}));
|
|
34
30
|
for (const operation of context.ir.promiseOperations) {
|
|
@@ -134,7 +130,7 @@ export const projectSemanticReturnValues = (context) => {
|
|
|
134
130
|
for (const callable of context.ir.callables)
|
|
135
131
|
for (const site of callable.returnSites) {
|
|
136
132
|
const returnNode = context.returnSiteNodes.get(site.returnSiteId);
|
|
137
|
-
const references =
|
|
133
|
+
const references = context.referenceNodesWithin(site.location);
|
|
138
134
|
for (const reference of references)
|
|
139
135
|
addSemanticGraphRelation(context.state, {
|
|
140
136
|
source: reference,
|