rea-agents 3.0.0 → 3.1.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 +14 -16
- package/dist/application/AnalysisContextQueries.js +21 -9
- package/dist/application/ApplicationWorkflowEvidenceResolver.js +19 -11
- package/dist/application/ArtifactInventory/policy.js +17 -0
- package/dist/application/ArtifactInventory/reader.js +1 -4
- package/dist/application/ArtifactInventory/scanCanonical.js +0 -3
- package/dist/application/ArtifactInventory/scanReader.js +7 -7
- package/dist/application/ArtifactInventory/types.js +1 -5
- package/dist/application/BinarySession.js +14 -16
- package/dist/application/BinarySessionRecords.js +31 -5
- package/dist/application/BinarySessionStatus.js +11 -5
- package/dist/application/BrowserEvidence.js +3 -5
- package/dist/application/CapabilityClientRequirements.js +26 -0
- package/dist/application/CapabilityInventory.js +134 -63
- package/dist/application/CrossVersionInventory.js +7 -6
- package/dist/application/ElectronActiveEvidence.js +55 -0
- package/dist/application/ElectronActiveObservationPort.js +1 -0
- package/dist/application/ElectronActiveObservationService.js +81 -0
- package/dist/application/EnhancedTools.js +22 -20
- package/dist/application/EvidenceBundleCommands.js +5 -1
- package/dist/application/EvidenceLedger.js +8 -1
- package/dist/application/JavaScriptReplayPermission.js +1 -1
- package/dist/application/JavaScriptReplayService.js +23 -15
- package/dist/application/ManagedRuntimeCorrelationService.js +9 -5
- package/dist/application/NodeRuntimeCharacterizationService.js +8 -9
- package/dist/application/ProcessCaptureLifecycle.js +5 -0
- package/dist/application/ProcessCli.js +2 -1
- package/dist/application/ProcessHarness.js +8 -3
- package/dist/application/ProcessNormalization.js +2 -1
- package/dist/application/ProjectPermissionStore.js +1 -0
- package/dist/application/ReferenceSourceImport.js +2 -2
- package/dist/application/SetupClientConfiguration.js +6 -1
- package/dist/application/WindowsCapabilities.js +5 -4
- package/dist/artifacts/ArtifactProvider.js +8 -10
- package/dist/artifacts/SafeOutputTree.js +7 -8
- package/dist/browser/CdpCaptureStorageFingerprints.js +10 -7
- package/dist/browser/CdpElectronInspection.js +3 -1
- package/dist/browser/JavaScriptRuntimeScope.js +5 -0
- package/dist/browser/PlaywrightElectronActiveActions.js +324 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +294 -0
- package/dist/browser/PlaywrightScenarioBrowser.js +4 -4
- package/dist/browser/PlaywrightScenarioSession.js +4 -4
- package/dist/browser/SensitiveTextCapture.js +1 -1
- package/dist/browser/V8InspectorCaptureProjection.js +1 -0
- package/dist/browser/V8InspectorProvider.js +3 -3
- package/dist/catalogIdentity.js +12 -6
- package/dist/cli/managedCommands.js +1 -1
- package/dist/cliApplicationCommands.js +2 -2
- package/dist/cliBrowserAdvancedCommands.js +11 -5
- package/dist/cliBrowserCommands.js +14 -7
- package/dist/cliCommandNames.js +1 -0
- package/dist/cliElectronCommands.js +46 -4
- package/dist/cliJavaScriptRuntimeCommands.js +14 -6
- package/dist/cliObservationOptions.js +4 -0
- package/dist/cliPolicyCommands.js +1 -0
- package/dist/config/browserScenario.js +77 -0
- package/dist/config/electronAutomation.js +35 -0
- package/dist/config/environment.js +6 -0
- package/dist/config/javascriptReplay.js +41 -0
- package/dist/config/managedRuntime.js +25 -0
- package/dist/config/parseConfig.js +56 -200
- package/dist/config/parsers.js +10 -1
- package/dist/config/passiveObservation.js +157 -0
- package/dist/config/processCapture.js +47 -0
- package/dist/contracts/applicationToolContracts.js +2 -5
- package/dist/contracts/applicationWorkflowInputContracts.js +86 -96
- package/dist/contracts/artifactToolContracts.js +27 -34
- package/dist/contracts/browserToolContracts.js +2 -2
- package/dist/contracts/electronToolContracts.js +30 -1
- package/dist/contracts/enhancedInputs.js +13 -29
- package/dist/contracts/functionWorkflowToolContracts.js +2 -3
- package/dist/contracts/managedToolContracts.js +4 -9
- package/dist/contracts/managedWorkflowExamples.js +12 -9
- package/dist/contracts/managedWorkflowToolContracts.js +30 -27
- package/dist/contracts/nativeToolContracts.js +2 -3
- package/dist/contracts/sessionToolSchemas.js +61 -0
- package/dist/contracts/toolContractExamples.js +1 -0
- package/dist/contracts/toolContractHelpers.js +23 -0
- package/dist/contracts/toolContracts.js +5 -77
- package/dist/contracts/toolEffects.js +15 -0
- package/dist/contracts/toolOutputSchemaGroups.js +17 -2
- package/dist/contracts/toolOutputSchemaPrimitives.js +76 -26
- package/dist/contracts/toolSchemaMetadata.js +128 -0
- package/dist/doctorRuntime.js +1 -1
- package/dist/domain/androidApplication.js +2 -0
- package/dist/domain/appleApplication.js +2 -0
- package/dist/domain/binaryTarget.js +7 -5
- package/dist/domain/binaryTargetTypes.js +1 -0
- package/dist/domain/browserCaptureComparison.js +21 -69
- package/dist/domain/browserObservation.js +22 -9
- package/dist/domain/bytecodeProvider.js +33 -35
- package/dist/domain/callPath.js +3 -2
- package/dist/domain/conformanceReplay.js +3 -3
- package/dist/domain/conformanceTrustGate.js +151 -16
- package/dist/domain/customProtocolCapture.js +3 -3
- package/dist/domain/electronActiveObservation.js +277 -0
- package/dist/domain/electronObservation.js +15 -11
- package/dist/domain/electronStaticAnalysisValues.js +4 -1
- package/dist/domain/eventProcessTree.js +82 -79
- package/dist/domain/functionComparisonNormalization.js +15 -8
- package/dist/domain/functionDossierEvidence.js +9 -4
- package/dist/domain/hopperValues.js +68 -71
- package/dist/domain/inputIssueProjection.js +4 -1
- package/dist/domain/investigationWorkspace.js +16 -15
- package/dist/domain/javascriptExportShapeComparisonSchemas.js +2 -2
- package/dist/domain/javascriptReplay.js +79 -63
- package/dist/domain/javascriptRuntimeObservation.js +1 -0
- package/dist/domain/javascriptRuntimeReconciliationActive.js +89 -0
- package/dist/domain/javascriptRuntimeReconciliationGraph.js +11 -10
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +57 -49
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +5 -1
- package/dist/domain/javascriptRuntimeReconciliationResult.js +21 -14
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +1 -1
- package/dist/domain/knownPageCoverage.js +15 -7
- package/dist/domain/nativeApiBoundary.js +15 -7
- package/dist/domain/nodeRuntimeCharacterization.js +14 -13
- package/dist/domain/processCaptureReactiveValidation.js +8 -3
- package/dist/domain/processCaptureValidation.js +7 -3
- package/dist/domain/processComparison.js +12 -7
- package/dist/domain/processObservation.js +5 -6
- package/dist/domain/processReactiveMatching.js +14 -7
- package/dist/domain/processReactiveTransition.js +9 -3
- package/dist/domain/processScenario.js +6 -3
- package/dist/domain/processTraceComparison.js +3 -2
- package/dist/domain/protocolCapture.js +8 -6
- package/dist/domain/reconstructionReadinessSchemas.js +30 -2
- package/dist/domain/referenceSourceImportParsing.js +2 -2
- package/dist/domain/replayMachineRuntime.js +5 -3
- package/dist/domain/sourceToBundleComparison.js +2 -2
- package/dist/domain/sourceToBundleComparisonSchemas.js +8 -8
- package/dist/domain/sourceToBundleSignals.js +7 -1
- package/dist/domain/staticRuntimeCorrelation.js +7 -5
- package/dist/domain/webBundleAnalysis.js +14 -14
- package/dist/domain/webCaptureDiff.js +15 -12
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +2 -3
- package/dist/generatedMcpToolCatalog.js +1 -1
- package/dist/generatedPackageMetadata.js +1 -1
- package/dist/ghidra/GhidraClient.js +1 -1
- package/dist/ghidra/GhidraClientStartup.js +1 -1
- package/dist/ghidra/GhidraFunctionValues.js +17 -15
- package/dist/ghidra/GhidraInventoryValues.js +57 -47
- package/dist/ghidra/GhidraProvider.js +18 -10
- package/dist/ghidra/GhidraProviderCapabilities.js +5 -1
- package/dist/ghidra/GhidraSocketConnection.js +1 -1
- package/dist/ghidra/protocol.js +19 -42
- package/dist/hopper/BridgeLauncher.js +3 -1
- package/dist/hopper/HopperAnalysisProfile.js +2 -4
- package/dist/hopper/HopperCleanup.js +5 -6
- package/dist/hopper/HopperClient.js +1 -1
- package/dist/hopper/HopperProvider.js +0 -14
- package/dist/hopper/LinuxPrivateDisplayProbe.js +16 -10
- package/dist/main/reload.js +1 -6
- package/dist/main/state.js +0 -14
- package/dist/main/transport.js +30 -37
- package/dist/main.js +17 -15
- package/dist/mcpDoctor.js +2 -24
- package/dist/process/PrivateRuntimeRoot.js +17 -0
- package/dist/process/ProcessOwnership.js +64 -128
- package/dist/process/ProcessOwnershipIdentity.js +13 -0
- package/dist/process/ProcessOwnershipObservation.js +88 -0
- package/dist/process/ProcessOwnershipProcessTree.js +22 -0
- package/dist/process/ProviderDeadline.js +8 -12
- package/dist/process/WindowsAuthority.js +32 -0
- package/dist/reference/ReferenceSourceReader.js +3 -3
- package/dist/reference/ReferenceSourceReaderEntries.js +2 -2
- package/dist/replay/JavaScriptReplayWorker.js +95 -11
- package/dist/replay/JavaScriptReplayWorkerTypes.js +1 -0
- package/dist/replay/LinuxJavaScriptReplayRunner.js +10 -15
- package/dist/replay/ReplayOutcome.js +26 -15
- package/dist/replay/ReplayWorkerProtocol.js +34 -29
- package/dist/server/createServer.js +158 -94
- package/dist/server/mcpClientMetadata.js +32 -0
- package/dist/server/registerApplicationTools/characterization.js +6 -13
- package/dist/server/registerApplicationTools/compareExportShapes.js +2 -7
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +2 -7
- package/dist/server/registerApplicationTools/compareVersions.js +3 -8
- package/dist/server/registerApplicationTools/controlledReplay.js +6 -11
- package/dist/server/registerApplicationTools/coverage.js +13 -19
- package/dist/server/registerApplicationTools/obligationLedger.js +1 -6
- package/dist/server/registerApplicationTools/readiness.js +1 -6
- package/dist/server/registerApplicationTools/traceFeature.js +3 -8
- package/dist/server/registerApplicationTools/traceSemantics.js +1 -6
- package/dist/server/registerArtifactComparisonTool.js +12 -16
- package/dist/server/registerBrowserScenarioTool.js +1 -6
- package/dist/server/registerBrowserTools.js +37 -79
- package/dist/server/registerBundleComparisonTool.js +10 -14
- package/dist/server/registerCloseLifecycleTool.js +6 -14
- package/dist/server/registerElectronTools.js +30 -47
- package/dist/server/registerEnhancedTools.js +114 -122
- package/dist/server/registerEvidenceTools.js +5 -9
- package/dist/server/registerFunctionComparisonTool.js +11 -15
- package/dist/server/registerInvestigationTools.js +41 -57
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +13 -27
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +4 -9
- package/dist/server/registerManagedWorkflowTools/contract.js +2 -3
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +3 -8
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +3 -8
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +8 -13
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +4 -9
- package/dist/server/registerOfficialTools.js +8 -9
- package/dist/server/registerProcessComparisonTool.js +19 -24
- package/dist/server/registerReplayMachineTool.js +4 -10
- package/dist/server/registerSessionRecordTools.js +69 -40
- package/dist/server/registerSessionStatusTool.js +13 -28
- package/dist/server/registerSessionTools.js +36 -52
- package/dist/server/sessionAvailabilityPolicy.js +2 -1
- package/dist/server/sessionToolPolicies.js +1 -5
- package/dist/server/toolRegistrationOptions.js +4 -192
- package/dist/server/toolResult.js +2 -18
- package/package.json +22 -14
- package/scripts/electron-active-hook-boundaries.cjs +394 -0
- package/scripts/electron-active-hook.cjs +501 -0
- package/scripts/rea.mjs +1 -11
- package/skills/reverse-engineer-anything/SKILL.md +2 -2
- package/dist/server/DynamicToolAvailability.js +0 -70
- package/dist/server/LazyToolCatalog.js +0 -134
- package/dist/server/hydrateServerTools.js +0 -191
- package/dist/server/toolInputValidation.js +0 -77
- package/scripts/package-runner-bootstrap.mjs +0 -72
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Stable explanation used whenever the native Windows authority is absent. */
|
|
2
|
+
export const WINDOWS_NATIVE_AUTHORITY_UNAVAILABLE_REASON = "Verified Windows native authority is unavailable: Job Object process ownership, private runtime DACL enforcement, and reparse-safe path admission are not implemented; chmod(0700) is insufficient for Windows private DACL proof, and taskkill is not a Job Object security proof";
|
|
3
|
+
/**
|
|
4
|
+
* Describe native Windows controls without inferring them from taskkill,
|
|
5
|
+
* chmod, symlink creation, or a numeric POSIX open flag.
|
|
6
|
+
*/
|
|
7
|
+
export const windowsNativeCapabilities = (platform) => {
|
|
8
|
+
if (platform !== "win32") {
|
|
9
|
+
const notApplicable = {
|
|
10
|
+
available: false,
|
|
11
|
+
reason: "Windows native authority is not applicable on this host",
|
|
12
|
+
proof: "not-applicable",
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
job_object_process_ownership: notApplicable,
|
|
16
|
+
private_runtime_dacl: notApplicable,
|
|
17
|
+
reparse_safe_path_admission: notApplicable,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const notProven = {
|
|
21
|
+
available: false,
|
|
22
|
+
reason: WINDOWS_NATIVE_AUTHORITY_UNAVAILABLE_REASON,
|
|
23
|
+
proof: "not-proven",
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
job_object_process_ownership: notProven,
|
|
27
|
+
private_runtime_dacl: notProven,
|
|
28
|
+
reparse_safe_path_admission: notProven,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/** Whether every native control needed for Windows isolation is proven. */
|
|
32
|
+
export const hasWindowsNativeAuthority = (platform) => Object.values(windowsNativeCapabilities(platform)).every(({ available }) => available);
|
|
@@ -35,7 +35,7 @@ export const readReferenceSource = async (root, limits = DEFAULT_LIMITS, options
|
|
|
35
35
|
bytesRead: 0,
|
|
36
36
|
filesSeen: 0,
|
|
37
37
|
truncated: false,
|
|
38
|
-
|
|
38
|
+
stopReason: undefined,
|
|
39
39
|
};
|
|
40
40
|
const traversal = await traverse(state);
|
|
41
41
|
if (!traversal.ok)
|
|
@@ -48,14 +48,14 @@ export const readReferenceSource = async (root, limits = DEFAULT_LIMITS, options
|
|
|
48
48
|
truncated: state.truncated,
|
|
49
49
|
limitations: [
|
|
50
50
|
PATH_RACE_LIMITATION,
|
|
51
|
-
...(state.
|
|
51
|
+
...(state.stopReason === "entry-limit"
|
|
52
52
|
? ["Traversal stopped because the entry limit was reached."]
|
|
53
53
|
: []),
|
|
54
54
|
],
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
const traverse = async (state) => {
|
|
58
|
-
while (state.pending.length > 0 &&
|
|
58
|
+
while (state.pending.length > 0 && state.stopReason === undefined) {
|
|
59
59
|
if (isAborted(state.signal))
|
|
60
60
|
return err({
|
|
61
61
|
tag: "reference-source-reader",
|
|
@@ -35,7 +35,7 @@ export const traverseDirectory = async (state, current) => {
|
|
|
35
35
|
const result = await processEntry(state, current, name, directories);
|
|
36
36
|
if (!result.ok)
|
|
37
37
|
return result;
|
|
38
|
-
if (state.
|
|
38
|
+
if (state.stopReason !== undefined)
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
41
|
directories.reverse();
|
|
@@ -201,6 +201,6 @@ const reserveEntry = (state) => {
|
|
|
201
201
|
return true;
|
|
202
202
|
}
|
|
203
203
|
state.truncated = true;
|
|
204
|
-
state.
|
|
204
|
+
state.stopReason = "entry-limit";
|
|
205
205
|
return false;
|
|
206
206
|
};
|
|
@@ -1,5 +1,82 @@
|
|
|
1
1
|
import { Script, SourceTextModule, SyntheticModule, createContext, } from "node:vm";
|
|
2
2
|
import { types } from "node:util";
|
|
3
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
const record = (value, label) => {
|
|
5
|
+
if (!isRecord(value))
|
|
6
|
+
throw new TypeError(`Invalid replay worker ${label}`);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
const string = (value, label) => {
|
|
10
|
+
if (typeof value !== "string")
|
|
11
|
+
throw new TypeError(`Invalid replay worker ${label}`);
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
14
|
+
const integer = (value, label) => {
|
|
15
|
+
if (!Number.isSafeInteger(value) || Number(value) < 0)
|
|
16
|
+
throw new TypeError(`Invalid replay worker ${label}`);
|
|
17
|
+
return Number(value);
|
|
18
|
+
};
|
|
19
|
+
const parseWorkerModule = (value) => {
|
|
20
|
+
const module = record(value, "module");
|
|
21
|
+
const format = module.format;
|
|
22
|
+
if (format !== "esm" && format !== "commonjs-factory")
|
|
23
|
+
throw new TypeError("Invalid replay worker module format");
|
|
24
|
+
const dependencies = record(module.dependencies, "module dependencies");
|
|
25
|
+
if (Object.values(dependencies).some((dependency) => typeof dependency !== "string"))
|
|
26
|
+
throw new TypeError("Invalid replay worker module dependency");
|
|
27
|
+
return {
|
|
28
|
+
alias: string(module.alias, "module alias"),
|
|
29
|
+
format,
|
|
30
|
+
dependencies: Object.fromEntries(Object.entries(dependencies).map(([key, dependency]) => [
|
|
31
|
+
key,
|
|
32
|
+
string(dependency, "module dependency"),
|
|
33
|
+
])),
|
|
34
|
+
source: string(module.source, "module source"),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const parseWorkerSide = (value) => {
|
|
38
|
+
const side = record(value, "side");
|
|
39
|
+
if (!Array.isArray(side.modules))
|
|
40
|
+
throw new TypeError("Invalid replay worker modules");
|
|
41
|
+
return {
|
|
42
|
+
modules: side.modules.map(parseWorkerModule),
|
|
43
|
+
entryAlias: string(side.entryAlias, "entry alias"),
|
|
44
|
+
entryExport: string(side.entryExport, "entry export"),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const parseWorkerRequest = (value) => {
|
|
48
|
+
const request = record(value, "request");
|
|
49
|
+
if (request.schemaVersion !== 1 || !Array.isArray(request.cases))
|
|
50
|
+
throw new TypeError("Unsupported replay worker protocol");
|
|
51
|
+
const determinism = record(request.determinism, "determinism");
|
|
52
|
+
const limits = record(request.limits, "limits");
|
|
53
|
+
return {
|
|
54
|
+
schemaVersion: 1,
|
|
55
|
+
left: parseWorkerSide(request.left),
|
|
56
|
+
...(request.right === undefined
|
|
57
|
+
? {}
|
|
58
|
+
: { right: parseWorkerSide(request.right) }),
|
|
59
|
+
cases: request.cases.map((value) => {
|
|
60
|
+
const replayCase = record(value, "case");
|
|
61
|
+
if (!Array.isArray(replayCase.arguments))
|
|
62
|
+
throw new TypeError("Invalid replay worker case arguments");
|
|
63
|
+
return {
|
|
64
|
+
caseId: string(replayCase.caseId, "case ID"),
|
|
65
|
+
arguments: replayCase.arguments,
|
|
66
|
+
inputSha256: string(replayCase.inputSha256, "case digest"),
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
determinism: {
|
|
70
|
+
clockIso: string(determinism.clockIso, "clock"),
|
|
71
|
+
randomSeed: integer(determinism.randomSeed, "random seed"),
|
|
72
|
+
},
|
|
73
|
+
limits: {
|
|
74
|
+
resultDepth: integer(limits.resultDepth, "result depth"),
|
|
75
|
+
resultNodes: integer(limits.resultNodes, "result nodes"),
|
|
76
|
+
exceptionBytes: integer(limits.exceptionBytes, "exception bytes"),
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
};
|
|
3
80
|
class ReplayDeniedError extends Error {
|
|
4
81
|
name = "ReplayDeniedError";
|
|
5
82
|
}
|
|
@@ -7,9 +84,8 @@ const main = async () => {
|
|
|
7
84
|
const chunks = [];
|
|
8
85
|
for await (const chunk of process.stdin)
|
|
9
86
|
chunks.push(Buffer.from(chunk));
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
throw new TypeError("Unsupported replay worker protocol");
|
|
87
|
+
const rawRequest = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
88
|
+
const request = parseWorkerRequest(rawRequest);
|
|
13
89
|
const left = [];
|
|
14
90
|
const right = [];
|
|
15
91
|
for (let index = 0; index < request.cases.length; index += 1) {
|
|
@@ -66,18 +142,20 @@ const loadEntry = async (side, request, caseIndex) => {
|
|
|
66
142
|
throw new TypeError(`Synchronous require cannot load ESM module: ${alias}`);
|
|
67
143
|
const module = { exports: {} };
|
|
68
144
|
commonJsCache.set(alias, module.exports);
|
|
69
|
-
const requireModule = (
|
|
145
|
+
const requireModule = (specifier) => {
|
|
70
146
|
const dependency = descriptor.dependencies[specifier];
|
|
71
147
|
if (dependency === undefined)
|
|
72
148
|
throw new ReplayDeniedError(`Undeclared require: ${specifier}`);
|
|
73
149
|
return loadCommonJs(dependency);
|
|
74
|
-
}
|
|
150
|
+
};
|
|
75
151
|
installRspackHelpers(requireModule);
|
|
76
152
|
const source = normalizeFactorySource(descriptor.source);
|
|
77
153
|
const factory = new Script(`(${source})`, {
|
|
78
154
|
filename: `/modules/${alias}.js`,
|
|
79
155
|
}).runInContext(context);
|
|
80
|
-
|
|
156
|
+
if (typeof factory !== "function")
|
|
157
|
+
throw new TypeError(`CommonJS factory is not callable: ${alias}`);
|
|
158
|
+
Reflect.apply(factory, undefined, [module, module.exports, requireModule]);
|
|
81
159
|
commonJsCache.set(alias, module.exports);
|
|
82
160
|
return module.exports;
|
|
83
161
|
};
|
|
@@ -126,7 +204,7 @@ const loadEntry = async (side, request, caseIndex) => {
|
|
|
126
204
|
: exported[side.entryExport];
|
|
127
205
|
}
|
|
128
206
|
const namespace = (await loadEsm(side.entryAlias)).namespace;
|
|
129
|
-
return namespace
|
|
207
|
+
return Reflect.get(namespace, side.entryExport);
|
|
130
208
|
};
|
|
131
209
|
const deterministicContext = (request, caseIndex) => {
|
|
132
210
|
let state = (request.determinism.randomSeed + caseIndex) >>> 0;
|
|
@@ -153,21 +231,27 @@ const deterministicContext = (request, caseIndex) => {
|
|
|
153
231
|
});
|
|
154
232
|
};
|
|
155
233
|
const installRspackHelpers = (require_) => {
|
|
156
|
-
|
|
234
|
+
const defineExports = (exports, definitions) => {
|
|
157
235
|
for (const [name, getter] of Object.entries(definitions))
|
|
158
236
|
if (!Object.prototype.hasOwnProperty.call(exports, name))
|
|
159
237
|
Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
160
238
|
};
|
|
161
|
-
|
|
239
|
+
const markModule = (exports) => {
|
|
162
240
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
163
241
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
164
242
|
};
|
|
165
|
-
|
|
243
|
+
const normalizeModule = (module) => {
|
|
166
244
|
const getter = () => (module.__esModule === true ? module.default : module);
|
|
167
245
|
Object.defineProperty(getter, "a", { get: getter });
|
|
168
246
|
return getter;
|
|
169
247
|
};
|
|
170
|
-
|
|
248
|
+
const passModule = (module) => module;
|
|
249
|
+
Object.defineProperties(require_, {
|
|
250
|
+
d: { value: defineExports },
|
|
251
|
+
r: { value: markModule },
|
|
252
|
+
n: { value: normalizeModule },
|
|
253
|
+
nmd: { value: passModule },
|
|
254
|
+
});
|
|
171
255
|
};
|
|
172
256
|
const requiredModule = (modules, alias) => {
|
|
173
257
|
const module = modules.get(alias);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -43,8 +43,7 @@ export class LinuxJavaScriptReplayRunner {
|
|
|
43
43
|
collected,
|
|
44
44
|
unitResult,
|
|
45
45
|
cleanup,
|
|
46
|
-
|
|
47
|
-
timedOut: replayProcess.timedOut,
|
|
46
|
+
termination: replayProcess.termination,
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
finally {
|
|
@@ -90,15 +89,14 @@ const launchReplayProcess = (options) => {
|
|
|
90
89
|
});
|
|
91
90
|
let child;
|
|
92
91
|
let timeout;
|
|
93
|
-
let
|
|
94
|
-
let timedOut = false;
|
|
92
|
+
let termination;
|
|
95
93
|
let terminationRequest;
|
|
96
94
|
const requestTermination = () => {
|
|
97
95
|
terminationRequest ??= killUnit(policy.systemctlPath, unit);
|
|
98
96
|
child?.kill("SIGKILL");
|
|
99
97
|
};
|
|
100
98
|
const terminate = () => {
|
|
101
|
-
|
|
99
|
+
termination ??= "cancelled";
|
|
102
100
|
requestTermination();
|
|
103
101
|
};
|
|
104
102
|
const completion = new Promise((resolve, reject) => {
|
|
@@ -124,7 +122,7 @@ const launchReplayProcess = (options) => {
|
|
|
124
122
|
if (isAborted(signal))
|
|
125
123
|
terminate();
|
|
126
124
|
timeout = setTimeout(() => {
|
|
127
|
-
|
|
125
|
+
termination ??= "timeout";
|
|
128
126
|
requestTermination();
|
|
129
127
|
}, prepared.publicPlan.limits.wall_time_ms);
|
|
130
128
|
timeout.unref();
|
|
@@ -139,11 +137,8 @@ const launchReplayProcess = (options) => {
|
|
|
139
137
|
get terminationRequest() {
|
|
140
138
|
return terminationRequest;
|
|
141
139
|
},
|
|
142
|
-
get
|
|
143
|
-
return
|
|
144
|
-
},
|
|
145
|
-
get timedOut() {
|
|
146
|
-
return timedOut;
|
|
140
|
+
get termination() {
|
|
141
|
+
return termination;
|
|
147
142
|
},
|
|
148
143
|
};
|
|
149
144
|
};
|
|
@@ -160,12 +155,12 @@ const replayProcessEnvironment = () => ({
|
|
|
160
155
|
: { DBUS_SESSION_BUS_ADDRESS: process.env.DBUS_SESSION_BUS_ADDRESS }),
|
|
161
156
|
});
|
|
162
157
|
const resolveReplayResult = (options) => {
|
|
163
|
-
const { prepared, collected, unitResult, cleanup,
|
|
164
|
-
if (
|
|
158
|
+
const { prepared, collected, unitResult, cleanup, termination } = options;
|
|
159
|
+
if (termination !== undefined)
|
|
165
160
|
return terminationResult({
|
|
166
161
|
prepared,
|
|
167
162
|
stderr: collected.stderr,
|
|
168
|
-
termination
|
|
163
|
+
termination,
|
|
169
164
|
cleanup,
|
|
170
165
|
});
|
|
171
166
|
if (collected.outputExceeded)
|
|
@@ -186,7 +181,7 @@ const resolveReplayResult = (options) => {
|
|
|
186
181
|
let response;
|
|
187
182
|
try {
|
|
188
183
|
const rawResponse = JSON.parse(collected.stdout);
|
|
189
|
-
response = parseReplayWorkerResponse(rawResponse, prepared.publicPlan.cases, prepared.publicPlan.right
|
|
184
|
+
response = parseReplayWorkerResponse(rawResponse, prepared.publicPlan.cases, prepared.publicPlan.right === undefined ? "single" : "differential");
|
|
190
185
|
}
|
|
191
186
|
catch {
|
|
192
187
|
return terminationResult({
|
|
@@ -33,18 +33,21 @@ const workerSide = (side, sources) => ({
|
|
|
33
33
|
entryExport: side.entry_export,
|
|
34
34
|
});
|
|
35
35
|
export const commitOutcomes = (outcomes) => outcomes.map((outcome) => {
|
|
36
|
-
|
|
36
|
+
if (outcome.outcome === "return")
|
|
37
|
+
return {
|
|
38
|
+
case_id: outcome.case_id,
|
|
39
|
+
outcome: outcome.outcome,
|
|
40
|
+
value: jsonValueSchema.parse(outcome.value),
|
|
41
|
+
input_sha256: outcome.input_sha256,
|
|
42
|
+
output_sha256: digestJson(outcome.value),
|
|
43
|
+
truncated: false,
|
|
44
|
+
};
|
|
37
45
|
return {
|
|
38
46
|
case_id: outcome.case_id,
|
|
39
47
|
outcome: outcome.outcome,
|
|
40
|
-
|
|
41
|
-
? {}
|
|
42
|
-
: { value: jsonValueSchema.parse(outcome.value) }),
|
|
43
|
-
...(outcome.exception === undefined
|
|
44
|
-
? {}
|
|
45
|
-
: { exception: outcome.exception }),
|
|
48
|
+
exception: outcome.exception,
|
|
46
49
|
input_sha256: outcome.input_sha256,
|
|
47
|
-
output_sha256: digestJson(
|
|
50
|
+
output_sha256: digestJson(outcome.exception),
|
|
48
51
|
truncated: false,
|
|
49
52
|
};
|
|
50
53
|
});
|
|
@@ -61,13 +64,21 @@ export const compareOutcomes = (left, right) => left.map((item, index) => ({
|
|
|
61
64
|
}));
|
|
62
65
|
export const terminationResult = (options) => {
|
|
63
66
|
const { prepared, stderr, termination, cleanup, limitation } = options;
|
|
64
|
-
const outcomes =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const outcomes = termination === "protocol_error"
|
|
68
|
+
? prepared.publicPlan.cases.map((item) => ({
|
|
69
|
+
case_id: item.case_id,
|
|
70
|
+
outcome: termination,
|
|
71
|
+
input_sha256: item.sha256,
|
|
72
|
+
output_sha256: null,
|
|
73
|
+
truncated: true,
|
|
74
|
+
}))
|
|
75
|
+
: prepared.publicPlan.cases.map((item) => ({
|
|
76
|
+
case_id: item.case_id,
|
|
77
|
+
outcome: termination,
|
|
78
|
+
input_sha256: item.sha256,
|
|
79
|
+
output_sha256: null,
|
|
80
|
+
truncated: false,
|
|
81
|
+
}));
|
|
71
82
|
const differential = prepared.publicPlan.right !== undefined;
|
|
72
83
|
return {
|
|
73
84
|
schema_version: 1,
|
|
@@ -1,45 +1,50 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
const
|
|
3
|
-
.object({
|
|
2
|
+
const workerOutcomeFacts = {
|
|
4
3
|
case_id: z.string(),
|
|
5
|
-
outcome: z.enum(["return", "exception", "serialization_error", "denied"]),
|
|
6
|
-
value: z.json().optional(),
|
|
7
|
-
exception: z
|
|
8
|
-
.object({
|
|
9
|
-
name: z.string(),
|
|
10
|
-
message: z.string(),
|
|
11
|
-
stack: z.string().nullable(),
|
|
12
|
-
})
|
|
13
|
-
.strict()
|
|
14
|
-
.optional(),
|
|
15
4
|
input_sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
16
5
|
output_sha256: z.null(),
|
|
17
6
|
truncated: z.literal(false),
|
|
7
|
+
};
|
|
8
|
+
const exceptionSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
name: z.string(),
|
|
11
|
+
message: z.string(),
|
|
12
|
+
stack: z.string().nullable(),
|
|
18
13
|
})
|
|
19
|
-
.strict()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
.strict();
|
|
15
|
+
const workerOutcomeSchema = z.discriminatedUnion("outcome", [
|
|
16
|
+
z.strictObject({
|
|
17
|
+
...workerOutcomeFacts,
|
|
18
|
+
outcome: z.literal("return"),
|
|
19
|
+
value: z.json(),
|
|
20
|
+
}),
|
|
21
|
+
z.strictObject({
|
|
22
|
+
...workerOutcomeFacts,
|
|
23
|
+
outcome: z.enum(["exception", "serialization_error", "denied"]),
|
|
24
|
+
exception: z.object(exceptionSchema.shape).strict(),
|
|
25
|
+
}),
|
|
26
|
+
]);
|
|
27
|
+
const singleWorkerResponseSchema = z
|
|
28
|
+
.object({
|
|
29
|
+
schema_version: z.literal(1),
|
|
30
|
+
left: z.array(workerOutcomeSchema),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
const differentialWorkerResponseSchema = z
|
|
29
34
|
.object({
|
|
30
35
|
schema_version: z.literal(1),
|
|
31
36
|
left: z.array(workerOutcomeSchema),
|
|
32
|
-
right: z.array(workerOutcomeSchema)
|
|
37
|
+
right: z.array(workerOutcomeSchema),
|
|
33
38
|
})
|
|
34
39
|
.strict();
|
|
35
40
|
/** Strictly authenticate case ordering and commitments in worker output. */
|
|
36
|
-
export const parseReplayWorkerResponse = (rawResponse, cases,
|
|
37
|
-
const response =
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
export const parseReplayWorkerResponse = (rawResponse, cases, mode) => {
|
|
42
|
+
const response = mode === "single"
|
|
43
|
+
? singleWorkerResponseSchema.parse(rawResponse)
|
|
44
|
+
: differentialWorkerResponseSchema.parse(rawResponse);
|
|
40
45
|
validateOutcomeSequence(response.left, cases);
|
|
41
|
-
if (
|
|
42
|
-
validateOutcomeSequence(response.right, cases);
|
|
46
|
+
if (mode === "differential")
|
|
47
|
+
validateOutcomeSequence(differentialWorkerResponseSchema.parse(response).right, cases);
|
|
43
48
|
return response;
|
|
44
49
|
};
|
|
45
50
|
const validateOutcomeSequence = (outcomes, cases) => {
|