From 39a82fd1ac23a2bf46f33729d81dd50be6cfa13d Mon Sep 17 00:00:00 2001 From: Aleksei Menshutin Date: Fri, 4 Dec 2026 05:11:00 +0100 Subject: [PATCH 1/2] Add a missing input method replay experiment --- .../scripts/test_missing_input_method.cjs | 133 ++++++++++++++ .../org/usvm/ts/calls/CallsClassOracle.kt | 20 ++- .../org/usvm/ts/calls/CallsExperimentCli.kt | 2 + .../CallsMissingInputMethodExperiment.kt | 133 ++++++++++++++ .../usvm/ts/calls/CallsSavedInputReplay.kt | 71 ++++++-- .../org/usvm/ts/calls/missing-input-method.js | 150 ++++++++++++++++ .../CallsMissingInputMethodExperimentTest.kt | 162 ++++++++++++++++++ 7 files changed, 654 insertions(+), 17 deletions(-) create mode 100644 usvm-ts-calls/scripts/test_missing_input_method.cjs create mode 100644 usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperiment.kt create mode 100644 usvm-ts-calls/src/main/resources/org/usvm/ts/calls/missing-input-method.js create mode 100644 usvm-ts-calls/src/test/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperimentTest.kt diff --git a/usvm-ts-calls/scripts/test_missing_input_method.cjs b/usvm-ts-calls/scripts/test_missing_input_method.cjs new file mode 100644 index 0000000000..eb6c08e3ac --- /dev/null +++ b/usvm-ts-calls/scripts/test_missing_input_method.cjs @@ -0,0 +1,133 @@ +'use strict'; + +const assert = require('node:assert/strict'); +const { execFileSync } = require('node:child_process'); +const fs = require('node:fs'); +const path = require('node:path'); +const { test } = require('node:test'); +const { types } = require('node:util'); +const vm = require('node:vm'); + +const sourcePath = path.join(__dirname, '../src/main/resources/org/usvm/ts/calls/missing-input-method.js'); +const source = fs.readFileSync(sourcePath, 'utf8'); +const { examineStructuralInput, observeMissingInputMethod } = vm.runInThisContext( + source + '\n({ examineStructuralInput, observeMissingInputMethod });', +); + +function fixture() { + class Fixture { + invoke() { + assert.equal(this.service, this.alias); + assert.equal(0 in this.values, false); + assert.equal(1 in this.values, true); + return this.service.missing(); + } + } + const owner = {}; + const values = [, undefined]; + const receiver = Object.assign(Object.create(Fixture.prototype), { service: owner, alias: owner, values }); + const objects = new Map([[0, receiver], [1, owner], [2, values]]); + const graph = { + receiver: { objectId: 0 }, + objects: [ + { + id: 0, className: 'Fixture', classSignature: 'Fixture', classSourceFile: 'fixture.ts', + fields: { service: { objectId: 1 }, alias: { objectId: 1 }, values: { objectId: 2 } }, + }, + { id: 1, fields: {} }, + { id: 2, elements: [null, { primitive: { kind: 'undefined' } }] }, + ], + }; + return { candidate: { invocationKind: 'INSTANCE_METHOD', inputs: graph }, owner, restored: { receiver, objects } }; +} + +test('one own method on the same object, with independent original and alternative runs', async () => { + const original = fixture(); + const alternative = fixture(); + const originalGraph = structuredClone(original.candidate.inputs); + const encode = value => ({ kind: typeof value }); + original.candidate.structural = { fields: ['service', 'missing'], install: false }; + alternative.candidate.structural = { fields: ['service', 'missing'], install: true }; + + const before = await observeMissingInputMethod( + original.candidate, original.restored, () => original.restored.receiver.invoke(), encode, types.isPromise, + ); + const after = await observeMissingInputMethod( + alternative.candidate, alternative.restored, () => alternative.restored.receiver.invoke(), encode, types.isPromise, + ); + const trace = JSON.parse(after.missingMethod); + + assert.equal(before.completion, 'THREW'); + assert.equal(JSON.parse(before.missingMethod).typeError, true); + assert.equal(after.completion, 'RETURNED'); + assert.equal(after.returnValue, '{"kind":"undefined"}'); + assert.deepEqual(trace.atCompletion, { + status: 'ELIGIBLE', installed: true, calls: 1, ownerCalls: 1, ownerId: 1, method: 'missing', + }); + assert.deepEqual(trace.unhandledRejections, []); + assert.deepEqual(Object.keys(alternative.owner), ['missing']); + assert.deepEqual(Object.keys(original.owner), []); + assert.equal(Object.getPrototypeOf(alternative.owner), Object.prototype); + assert.deepEqual(alternative.candidate.inputs, originalGraph); +}); + +test('guard refuses existing methods, prototype roots, accessors and primitive owners', () => { + const cases = [ + ['own non-callable', f => { f.owner.missing = undefined; }, 'METHOD_ALREADY_PRESENT'], + ['own accessor', f => { + Object.defineProperty(f.owner, 'missing', { get() { throw Error('must not run'); } }); + }, 'METHOD_ALREADY_PRESENT'], + ['inherited name', f => { f.candidate.structural.fields[1] = 'toString'; }, 'METHOD_ALREADY_PRESENT'], + ['missing link', f => { f.candidate.structural.fields[0] = 'unrecorded'; }, 'PATH_NOT_OWN_GRAPH_REFERENCE'], + ['intermediate accessor', f => { + Object.defineProperty(f.restored.receiver, 'service', { get() { throw Error('must not run'); } }); + }, 'PATH_NOT_OWN_GRAPH_REFERENCE'], + ['array owner', f => { f.candidate.structural.fields[0] = 'values'; }, 'OWNER_NOT_ORDINARY_PLAIN_OBJECT'], + ['custom prototype', f => { Object.setPrototypeOf(f.owner, {}); }, 'OWNER_NOT_ORDINARY_PLAIN_OBJECT'], + ['class-tagged owner', f => { f.candidate.inputs.objects[1].className = 'Custom'; }, 'OWNER_NOT_ORDINARY_PLAIN_OBJECT'], + ['unqualified path token', f => { f.candidate.structural.fields[1] = 'a.b'; }, 'UNSUPPORTED_METHOD_PATH'], + ['non-extensible owner', f => { Object.freeze(f.owner); }, 'OWNER_NOT_EXTENSIBLE'], + ['primitive link', f => { + f.candidate.inputs.objects[0].fields.service = { primitive: { kind: 'boolean', value: false } }; + f.restored.receiver.service = false; + }, 'PATH_NOT_OWN_GRAPH_REFERENCE'], + ]; + for (const [name, prepare, status] of cases) { + const f = fixture(); + f.candidate.structural = { fields: ['service', 'missing'], install: true }; + prepare(f); + + const result = examineStructuralInput(f.candidate, f.restored); + + assert.equal(result.status, status, name); + assert.equal(result.installed, false, name); + } +}); + +test('separates a return from a later unhandled rejection in the native process', () => { + const script = source + ` + const candidate = { + invocationKind: 'INSTANCE_METHOD', + structural: { fields: ['missing'], install: true }, + inputs: { receiver: { objectId: 0 }, objects: [{ id: 0, fields: {} }] }, + }; + const receiver = {}; + const restored = { receiver, objects: new Map([[0, receiver]]) }; + observeMissingInputMethod(candidate, restored, () => { + receiver.missing(); + Promise.reject(new Error('later')); + return 7; + }, value => value, require('node:util').types.isPromise).then(result => { + process.stdout.write(JSON.stringify(result)); + }); + `; + + const result = JSON.parse(execFileSync(process.execPath, ['--unhandled-rejections=throw', '-e', script], { + encoding: 'utf8', timeout: 10000, + })); + const trace = JSON.parse(result.missingMethod); + + assert.equal(result.completion, 'RETURNED'); + assert.equal(trace.atCompletion.ownerCalls, 1); + assert.deepEqual(trace.unhandledRejections, [{ errorType: 'Error', message: 'later', handledWithinWindow: false }]); +}); diff --git a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsClassOracle.kt b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsClassOracle.kt index 01b3527cad..1bc9c50a33 100644 --- a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsClassOracle.kt +++ b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsClassOracle.kt @@ -25,6 +25,7 @@ import org.usvm.ts.pbt.fastcheck.FastCheckRuntime import org.usvm.ts.pbt.fastcheck.TypeScriptLocalSourceClosure import org.usvm.ts.pbt.model.ArrayDomain import org.usvm.ts.pbt.model.BooleanDomain +import org.usvm.ts.pbt.model.ExecutionKind import org.usvm.ts.pbt.model.ConstantDomain import org.usvm.ts.pbt.model.IntegerDomain import org.usvm.ts.pbt.model.JsConcreteValue @@ -273,6 +274,7 @@ internal class OriginalTypeScriptClassReplayer( // Saved environments may replay naturally evaluated initializers outside the lifecycle oracle's checked subset. // The supplied graph still passes the normal copy/hash checks and cannot contain unresolved module boundaries. sourceClosure: TypeScriptLocalSourceClosure? = null, + private val awaitPreparedObservation: Boolean = false, ) : AutoCloseable { private val root = sourceRoot.toRealPath() private val workspace = Files.createTempDirectory("usvm-calls-class-replay-") @@ -314,6 +316,7 @@ internal class OriginalTypeScriptClassReplayer( dropSentinel = function.inputs.isEmpty(), counterGlobalName = counterGlobalName, fields = observationFields.keys, + awaitPreparedObservation = awaitPreparedObservation, ) ) FastCheckBackend(sourceRoots = listOf(overlay), tsconfig = tsconfig) @@ -365,7 +368,11 @@ internal class OriginalTypeScriptClassReplayer( property = PropertyDefinition( id = PropertyId("calls.class.exact-replay"), inputs = propertyInputs, - predicate = TypeScriptEntryPoint(module = wrapperName, exportName = "replayClassScenario"), + predicate = TypeScriptEntryPoint( + module = wrapperName, + exportName = "replayClassScenario", + executionKind = if (awaitPreparedObservation) ExecutionKind.ASYNC else ExecutionKind.SYNC, + ), ), configuration = PropertyRunConfiguration( seed = nativeSeed, @@ -402,6 +409,7 @@ private fun classReplayWrapper( dropSentinel: Boolean, counterGlobalName: String?, fields: Set, + awaitPreparedObservation: Boolean, ): String { val json = CallsExperimentJson.json val protocolModule = json.encodeToUtf8SafeString(FastCheckRuntime.protocolJsonModule().toUri().toString()) @@ -410,6 +418,11 @@ private fun classReplayWrapper( val outputPath = json.encodeToUtf8SafeString(observationPath.toString()) val expectedFields = json.encodeToUtf8SafeString(fields.sorted()) val actualArgs = if (dropSentinel) "args.slice(1)" else "args" + val async = if (awaitPreparedObservation) "async " else "" + val await = if (awaitPreparedObservation) "await " else "" + val returnType = if (awaitPreparedObservation) "Promise" else "boolean" + val promiseCheckImport = if (awaitPreparedObservation) "import { types as nodeTypes } from 'node:util';" else "" + val promiseCheckArgument = if (awaitPreparedObservation) ", nodeTypes.isPromise" else "" val counterSetup = counterGlobalName?.let { name -> "(globalThis as any)[${json.encodeToUtf8SafeString( name @@ -422,12 +435,13 @@ private fun classReplayWrapper( import { writeFileSync } from 'node:fs'; import { stringifyProtocolJson } from $protocolModule; import * as scenarioModule from $sourceModule; + $promiseCheckImport ${classReplayValueEncoderSource().prependIndent(indent = " ")} ${classReplayThrownValueDiagnosticSource().prependIndent(indent = " ")} - export function replayClassScenario(...args: unknown[]): boolean { + export ${async}function replayClassScenario(...args: unknown[]): $returnType { const actualArgs = $actualArgs; const inputs = actualArgs.map(value => encode(value)); $counterSetup @@ -435,7 +449,7 @@ ${classReplayThrownValueDiagnosticSource().prependIndent(indent = " ")} let returned: any; let completion = 'RETURNED'; try { - returned = (scenarioModule as any)[$exportKey](...actualArgs); + returned = ${await}(scenarioModule as any)[$exportKey](...actualArgs$promiseCheckArgument); } catch (error) { completion = 'THREW'; const isShapeFailure = error instanceof Error && error.message.startsWith('USVM class observation shape:'); diff --git a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsExperimentCli.kt b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsExperimentCli.kt index 54669121ee..b81e50729f 100644 --- a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsExperimentCli.kt +++ b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsExperimentCli.kt @@ -13,6 +13,7 @@ fun main(args: Array) { "class-start-smoke" -> runClassStartSmoke(args.drop(1)) "class-symbolic-probe" -> runClassSymbolicProbe(args.drop(1)) "class-replay-input" -> runSavedInputReplay(args.drop(1)) + "class-experiment-missing-input-method" -> runSavedInputReplay(args.drop(1), experiment = true) "class-prepare" -> runClassPrepare(args.drop(1)) "class-preflight" -> runClassPreflight(args.drop(1)) "class-cell" -> runClassCell(args.drop(1)) @@ -110,6 +111,7 @@ private fun usage(): String = """ calls class-start-smoke calls class-symbolic-probe calls class-replay-input + calls class-experiment-missing-input-method calls class-prepare calls class-preflight calls class-cell diff --git a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperiment.kt b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperiment.kt new file mode 100644 index 0000000000..2d63556721 --- /dev/null +++ b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperiment.kt @@ -0,0 +1,133 @@ +package org.usvm.ts.calls + +import kotlinx.serialization.Serializable +import org.usvm.ts.pbt.model.JsConcreteValue + +private val methodPathToken = Regex("[A-Za-z_$][A-Za-z0-9_$]*") + +@Serializable +internal data class CallsMissingInputMethodObservation( + val fields: List, + val errorMessage: String, +) { + init { + val validNames = fields.isNotEmpty() && fields.all { it.matches(methodPathToken) } + require(validNames) { "The observation must name a literal property chain relative to this" } + require(errorMessage == "this.${fields.joinToString(".")} is not a function") { + "The observed TypeError message must name the same missing method" + } + } +} + +@Serializable +internal data class CallsMissingInputMethodExecution(val fields: List, val install: Boolean) + +@Serializable +internal data class CallsMissingInputMethodDecision( + val status: String, + val installed: Boolean, + val calls: Int, + val ownerCalls: Int, + val ownerId: Int? = null, + val method: String? = null, +) + +@Serializable +internal data class CallsMissingInputMethodRejection( + val errorType: String, + val message: String, + val handledWithinWindow: Boolean, +) + +@Serializable +internal data class CallsMissingInputMethodTrace( + val atCompletion: CallsMissingInputMethodDecision, + val afterDrain: CallsMissingInputMethodDecision, + val typeError: Boolean, + val returnedPromise: Boolean, + val unhandledRejections: List, +) + +@Serializable +internal data class CallsMissingInputMethodRun( + val replay: CallsSavedInputReplayResult, + val trace: CallsMissingInputMethodTrace?, +) { + fun text(name: String): String? = (replay.observation?.observation?.values?.get(name) as? JsConcreteValue.String)?.value +} + +@Serializable +internal enum class CallsMissingInputMethodVerdict { + ORIGINAL_UNAVAILABLE, + NO_MATCHING_ORIGINAL_ERROR, + OWNER_INELIGIBLE, + ALTERNATIVE_UNAVAILABLE, + ADDED_METHOD_NOT_INVOKED_WITH_OWNER, + ALTERNATIVE_THREW, + RETURNED_PROMISE, + RETURNED_WITH_UNHANDLED_REJECTION, + RETURNED, +} + +/** Each run restores its own copy of the recorded heap in a fresh native process. */ +@Serializable +internal data class CallsMissingInputMethodResult( + val original: CallsMissingInputMethodRun, + val alternative: CallsMissingInputMethodRun?, + val verdict: CallsMissingInputMethodVerdict, +) + +internal fun replayMissingInputMethod( + observation: CallsMissingInputMethodObservation, + replay: (CallsMissingInputMethodExecution) -> CallsSavedInputReplayResult, +): CallsMissingInputMethodResult { + val original = replay(CallsMissingInputMethodExecution(observation.fields, install = false)).missingMethodRun() + val originalTrace = original.trace + if (originalTrace == null) { + return CallsMissingInputMethodResult( + original, alternative = null, verdict = CallsMissingInputMethodVerdict.ORIGINAL_UNAVAILABLE, + ) + } + + val matchesOriginal = original.text("completion") == "THREW" && originalTrace.typeError && + original.text("diagnostic") == "TypeError: ${observation.errorMessage}" + if (!matchesOriginal) { + return CallsMissingInputMethodResult( + original, alternative = null, verdict = CallsMissingInputMethodVerdict.NO_MATCHING_ORIGINAL_ERROR, + ) + } + if (originalTrace.atCompletion.status != "ELIGIBLE") { + return CallsMissingInputMethodResult( + original, alternative = null, verdict = CallsMissingInputMethodVerdict.OWNER_INELIGIBLE, + ) + } + + val alternative = replay(CallsMissingInputMethodExecution(observation.fields, install = true)).missingMethodRun() + val trace = alternative.trace + val completion = alternative.text("completion") + val verdict = when { + trace == null || !trace.atCompletion.installed -> CallsMissingInputMethodVerdict.ALTERNATIVE_UNAVAILABLE + trace.atCompletion.ownerCalls == 0 -> CallsMissingInputMethodVerdict.ADDED_METHOD_NOT_INVOKED_WITH_OWNER + completion == "THREW" -> CallsMissingInputMethodVerdict.ALTERNATIVE_THREW + completion != "RETURNED" -> CallsMissingInputMethodVerdict.ALTERNATIVE_UNAVAILABLE + trace.returnedPromise -> CallsMissingInputMethodVerdict.RETURNED_PROMISE + trace.unhandledRejections.isNotEmpty() -> CallsMissingInputMethodVerdict.RETURNED_WITH_UNHANDLED_REJECTION + else -> CallsMissingInputMethodVerdict.RETURNED + } + return CallsMissingInputMethodResult(original, alternative, verdict) +} + +private fun CallsSavedInputReplayResult.missingMethodRun(): CallsMissingInputMethodRun { + val observation = observation ?: return CallsMissingInputMethodRun(this, trace = null) + val values = observation.observation.values + val encoded = values["missingMethod"] as? JsConcreteValue.String + ?: return CallsMissingInputMethodRun(this, trace = null) + + val trace = CallsExperimentJson.json.decodeFromString(encoded.value) + val report = observation.copy(observation = observation.observation.copy(values = values - "missingMethod")) + return CallsMissingInputMethodRun(copy(observation = report), trace) +} + +internal fun missingInputMethodSource(): String = + checkNotNull(CallsMissingInputMethodObservation::class.java.getResourceAsStream("missing-input-method.js")) + .bufferedReader().use { it.readText() } diff --git a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsSavedInputReplay.kt b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsSavedInputReplay.kt index 63e345915d..29b7ac4701 100644 --- a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsSavedInputReplay.kt +++ b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsSavedInputReplay.kt @@ -36,9 +36,12 @@ internal data class CallsSavedInputReplayResult( ) /** Select one immutable journal record and verify both frozen inputs and its producing probe manifest. */ -internal fun runSavedInputReplay(args: List) { - require(args.size == SAVED_INPUT_REPLAY_ARGUMENT_COUNT) { - "class-replay-input needs " +internal fun runSavedInputReplay(args: List, experiment: Boolean = false) { + val command = if (experiment) "class-experiment-missing-input-method" else "class-replay-input" + val experimentArgument = if (experiment) " " else "" + val expectedArguments = SAVED_INPUT_REPLAY_ARGUMENT_COUNT + if (experiment) 1 else 0 + require(args.size == expectedArguments) { + "$command needs $experimentArgument " } val arguments = args.iterator() val manifestArgument = arguments.next() @@ -46,6 +49,12 @@ internal fun runSavedInputReplay(args: List) { val probeArgument = arguments.next() val stateId = arguments.next() val timeoutMillis = arguments.next().toLong() + val observation = if (experiment) { + val observationPath = Path.of(arguments.next()) + CallsExperimentJson.json.decodeFromString(Files.readString(observationPath)) + } else { + null + } val outputArgument = arguments.next() val manifestPath = Path.of(manifestArgument).toRealPath() val manifestBytes = Files.readAllBytes(manifestPath) @@ -78,18 +87,25 @@ internal fun runSavedInputReplay(args: List) { require(candidate.className == case.className && candidate.profile == manifest.profile) { "Saved candidate differs from the manifest class or profile" } - val replay = replayCallsSavedInput( + fun replay(missingMethod: CallsMissingInputMethodExecution?) = replayCallsSavedInput( sourceRoot = root, sourceFile = case.sourceFile, targetSignature = checkNotNull(result.targetSignature), candidate = candidate, timeoutMillis = timeoutMillis, + missingMethod = missingMethod, ) + + val report = if (observation == null) { + encodeCallsArtifact(replay(missingMethod = null)) + } else { + encodeCallsArtifact(replayMissingInputMethod(observation, ::replay)) + } case.verifyInputs() val output = Path.of(outputArgument).toAbsolutePath().normalize() output.parent?.let(Files::createDirectories) - Files.writeString(output, encodeCallsArtifact(replay) + "\n", StandardOpenOption.CREATE_NEW) + Files.writeString(output, report + "\n", StandardOpenOption.CREATE_NEW) } /** Reuses the normal frozen-closure copier, supervised native process and class observation transport. */ @@ -99,6 +115,7 @@ internal fun replayCallsSavedInput( targetSignature: String, candidate: CallsClassInputCandidate, timeoutMillis: Long, + missingMethod: CallsMissingInputMethodExecution? = null, ): CallsSavedInputReplayResult { require(timeoutMillis > 0) if (!candidate.environmentComplete) { @@ -154,7 +171,10 @@ internal fun replayCallsSavedInput( Files.writeString(workspace.resolve(file), preparedSource) } val harnessName = ".usvm-saved-input-${UUID.randomUUID()}.mts" - Files.writeString(workspace.resolve(harnessName), savedInputHarness(candidate = candidate, plan = plan)) + Files.writeString( + workspace.resolve(harnessName), + savedInputHarness(candidate = candidate, plan = plan, missingMethod = missingMethod), + ) val function = CallsFunctionCase( functionId = "calls.saved-input.${candidate.stateId}", sourceFile = harnessName, @@ -162,12 +182,13 @@ internal fun replayCallsSavedInput( inputs = emptyList(), targets = emptyList(), ) - val fields = mapOf( - "completion" to StringDomain(), - "returnValue" to StringDomain(maxLength = Int.MAX_VALUE), - "returnValueRepresentable" to BooleanDomain, - "diagnostic" to StringDomain(maxLength = Int.MAX_VALUE), - ) + val fields = buildMap { + put("completion", StringDomain()) + put("returnValue", StringDomain(maxLength = Int.MAX_VALUE)) + put("returnValueRepresentable", BooleanDomain) + put("diagnostic", StringDomain(maxLength = Int.MAX_VALUE)) + if (missingMethod != null) put("missingMethod", StringDomain(maxLength = Int.MAX_VALUE)) + } val preparedClosure = savedInputSourceClosure(root = workspace, sourceFile = harnessName) val preparedClosureResolved = preparedClosure.reasonCode == null && preparedClosure.resolution?.runtimeBoundaries.orEmpty().isEmpty() @@ -179,6 +200,7 @@ internal fun replayCallsSavedInput( function = function, observationFields = fields, sourceClosure = preparedClosure, + awaitPreparedObservation = missingMethod != null, ).use { replayer -> replayer.replay(inputs = emptyList(), timeoutMillis = timeoutMillis) } val invoked = observation.observation.completion == CallsCoverageCompletion.RETURNED && observation.observation.representable @@ -190,6 +212,14 @@ internal fun replayCallsSavedInput( observation = observation, sourceInitializationDiagnostics = closure.initializationIssues.map { it.diagnostic }, ) + } catch (failure: Exception) { + if (missingMethod == null) throw failure + + return CallsSavedInputReplayResult( + stateId = candidate.stateId, + status = CallsSavedInputReplayStatus.HARNESS_FAILURE, + diagnostic = failure.message ?: failure.javaClass.simpleName, + ) } finally { Files.walk(workspace).use { paths -> paths.sorted(Comparator.reverseOrder()).forEach(Files::deleteIfExists) } } @@ -287,7 +317,11 @@ private fun savedInputBindingPlan( return SavedInputBindingPlan(modules = bindings, classes = classes, targetSignature = targetSignature) } -private fun savedInputHarness(candidate: CallsClassInputCandidate, plan: SavedInputBindingPlan): String { +private fun savedInputHarness( + candidate: CallsClassInputCandidate, + plan: SavedInputBindingPlan, + missingMethod: CallsMissingInputMethodExecution?, +): String { val json = CallsExperimentJson.json val aliases = plan.modules.keys.withIndex().associate { (index, file) -> file to "module$index" } val imports = plan.modules.map { (file, bindings) -> @@ -315,12 +349,20 @@ private fun savedInputHarness(candidate: CallsClassInputCandidate, plan: SavedIn CallsClassInvocationKind.STATIC_METHOD, CallsClassInvocationKind.INSTANCE_METHOD -> "Reflect.apply(callable, receiver, restored.arguments)" } + val missingMethodSupport = if (missingMethod == null) "" else missingInputMethodSource() + val promiseCheck = if (missingMethod == null) "" else "isPromise: (value: unknown) => boolean" + val runExperiment = if (missingMethod == null) "" else """ + candidate.structural = ${encodeCallsArtifact(missingMethod)}; + return observeMissingInputMethod(candidate, restored, () => $invocation, encode, isPromise); + """.trimIndent() + return """ ${imports.joinToString("\n")} + $missingMethodSupport ${callsConcretePrimitiveDecoderSource()} ${callsConcreteHeapRestoreSource()} ${classReplayValueEncoderSource()} - export function invokeSavedInput(): any { + export function invokeSavedInput($promiseCheck): any { const candidate = JSON.parse(${json.encodeToUtf8SafeString(encodeCallsArtifact(candidate))}); const classes = new Map([${classes.joinToString()}]); const prototypes = new Map(Array.from(classes, ([signature, owner]) => [signature, owner.prototype] as const)); @@ -332,6 +374,7 @@ private fun savedInputHarness(candidate: CallsClassInputCandidate, plan: SavedIn const receiver = $receiver; const callable = $callable; if (typeof callable !== 'function') throw Error('Saved input native callable is unavailable'); + $runExperiment let returned: any; try { returned = $invocation; } catch (error) { const diagnostic = error instanceof Error ? error.name + ': ' + error.message : 'Thrown ' + typeof error; diff --git a/usvm-ts-calls/src/main/resources/org/usvm/ts/calls/missing-input-method.js b/usvm-ts-calls/src/main/resources/org/usvm/ts/calls/missing-input-method.js new file mode 100644 index 0000000000..6d6158efaf --- /dev/null +++ b/usvm-ts-calls/src/main/resources/org/usvm/ts/calls/missing-input-method.js @@ -0,0 +1,150 @@ +function examineStructuralInput(candidate, restored) { + const decision = { status: 'NO_MISSING_METHOD_RULE', installed: false, calls: 0, ownerCalls: 0 }; + const fields = candidate.structural?.fields; + if (fields == null) return decision; + if (candidate.invocationKind !== 'INSTANCE_METHOD') { + decision.status = 'ENTRY_HAS_NO_INPUT_RECEIVER'; + return decision; + } + + const validPath = Array.isArray(fields) && fields.length > 0 && fields.every(name => + typeof name === 'string' && /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name)); + if (!validPath) { + decision.status = 'UNSUPPORTED_METHOD_PATH'; + return decision; + } + + const byId = new Map(candidate.inputs.objects.map(node => [node.id, node])); + let slot = candidate.inputs.receiver; + let value = restored.receiver; + for (const key of fields.slice(0, -1)) { + const node = byId.get(slot?.objectId); + if (!node || !node.fields || !Object.hasOwn(node.fields, key)) { + decision.status = 'PATH_NOT_OWN_GRAPH_REFERENCE'; + return decision; + } + + const descriptor = Object.getOwnPropertyDescriptor(value, key); + slot = node.fields[key]; + const next = restored.objects.get(slot.objectId); + if (!next || !descriptor || !Object.hasOwn(descriptor, 'value') || descriptor.value !== next) { + decision.status = 'PATH_NOT_OWN_GRAPH_REFERENCE'; + return decision; + } + value = next; + } + + const owner = byId.get(slot?.objectId); + if (!owner) { + decision.status = 'OWNER_NOT_GRAPH_OBJECT'; + return decision; + } + + if (value !== restored.objects.get(owner.id) || owner.elements != null || owner.classSignature != null || + owner.classSourceFile != null || owner.className != null || Object.getPrototypeOf(value) !== Object.prototype) { + decision.status = 'OWNER_NOT_ORDINARY_PLAIN_OBJECT'; + return decision; + } + + const method = fields.at(-1); + if (Reflect.has(value, method)) { + decision.status = 'METHOD_ALREADY_PRESENT'; + return decision; + } + if (!Object.isExtensible(value)) { + decision.status = 'OWNER_NOT_EXTENSIBLE'; + return decision; + } + + decision.status = 'ELIGIBLE'; + decision.ownerId = owner.id; + decision.method = method; + if (candidate.structural.install) { + Object.defineProperty(value, method, { + value: function () { + decision.calls++; + if (this === value) decision.ownerCalls++; + return undefined; + }, + writable: true, + enumerable: true, + configurable: true, + }); + decision.installed = true; + } + return decision; +} + +async function observeMissingInputMethod(candidate, restored, invoke, encode, isPromise) { + const decision = examineStructuralInput(candidate, restored); + if (candidate.structural.install && !decision.installed) { + return { + completion: 'NOT_INVOKED', returnValue: '', returnValueRepresentable: false, diagnostic: '', + missingMethod: JSON.stringify({ + atCompletion: decision, afterDrain: decision, typeError: false, returnedPromise: false, + unhandledRejections: [], + }), + }; + } + + const rejections = new Map(); + function onRejection(reason, promise) { + let errorType = typeof reason; + let message = ''; + try { + if (reason instanceof Error) errorType = reason.name; + message = (reason instanceof Error ? reason.message : String(reason)).slice(0, 1000); + } catch { + errorType = 'UNREADABLE'; + } + rejections.set(promise, { errorType, message, handledWithinWindow: false }); + } + function onHandled(promise) { + const report = rejections.get(promise); + if (report) report.handledWithinWindow = true; + } + + process.on('unhandledRejection', onRejection); + process.on('rejectionHandled', onHandled); + try { + let completion = 'RETURNED'; + let diagnostic = ''; + let typeError = false; + let returnedPromise = false; + let value; + try { + value = invoke(); + returnedPromise = isPromise(value); + } catch (error) { + completion = 'THREW'; + typeError = error instanceof TypeError; + diagnostic = error instanceof Error ? error.name + ': ' + error.message : 'Thrown ' + typeof error; + } + const atCompletion = { ...decision }; + + let returnValue = ''; + let returnValueRepresentable = false; + if (completion === 'RETURNED' && !returnedPromise) { + try { + returnValue = JSON.stringify(encode(value)); + returnValueRepresentable = true; + } catch (error) { + diagnostic = error instanceof Error ? error.message : 'Unrepresentable return value'; + } + } + + await Promise.resolve(); + await new Promise(resolve => setImmediate(resolve)); + await new Promise(resolve => setImmediate(resolve)); + + return { + completion, returnValue, returnValueRepresentable, diagnostic, + missingMethod: JSON.stringify({ + atCompletion, afterDrain: decision, typeError, returnedPromise, unhandledRejections: [...rejections.values()], + }), + }; + } finally { + process.off('unhandledRejection', onRejection); + process.off('rejectionHandled', onHandled); + } +} diff --git a/usvm-ts-calls/src/test/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperimentTest.kt b/usvm-ts-calls/src/test/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperimentTest.kt new file mode 100644 index 0000000000..49cbfda808 --- /dev/null +++ b/usvm-ts-calls/src/test/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperimentTest.kt @@ -0,0 +1,162 @@ +package org.usvm.ts.calls + +import org.jacodb.ets.model.EtsClassSignature +import org.jacodb.ets.model.EtsFileSignature +import org.junit.jupiter.api.io.TempDir +import org.usvm.ts.pbt.model.JsConcreteValue +import java.nio.file.Files +import java.nio.file.Path +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotNull +import kotlin.test.assertNull + +class CallsMissingInputMethodExperimentTest { + @TempDir + lateinit var directory: Path + + @Test + fun `separates the original TypeError from an alternative return`() { + val fixture = fixture("invoke") + val expectedError = CallsExperimentJson.json.decodeFromString( + """{"fields":["service","missing"],"errorMessage":"this.service.missing is not a function"}""", + ) + + val experiment = replayMissingInputMethod(expectedError) { execution -> + replay(fixture, execution) + } + val ordinary = replay(fixture) + + assertEquals(CallsMissingInputMethodVerdict.RETURNED, experiment.verdict, experiment.toString()) + assertEquals("THREW", experiment.original.text("completion")) + assertEquals(false, experiment.original.trace?.atCompletion?.installed) + assertEquals(0, experiment.original.trace?.atCompletion?.calls) + assertEquals("TypeError: this.service.missing is not a function", experiment.original.text("diagnostic")) + val alternative = assertNotNull(experiment.alternative) + val trace = assertNotNull(alternative.trace) + assertEquals("RETURNED", alternative.text("completion")) + val returned = CallsExperimentJson.json.decodeFromString( + requireNotNull(alternative.text("returnValue")), + ) + assertEquals(JsConcreteValue.number(7.0), returned) + assertEquals(1, trace.atCompletion.ownerId) + assertEquals(1, trace.atCompletion.ownerCalls) + assertFalse(alternative.replay.nativeReplayValidated) + assertFalse(alternative.replay.nativeCoverageAvailable) + val originalValues = assertNotNull(ordinary.observation).observation.values + assertEquals(originalValues, experiment.original.replay.observation?.observation?.values) + } + + @Test + fun `keeps the alternative absent when the observed error differs`() { + val fixture = fixture("invoke") + val executions = mutableListOf() + + val result = replayMissingInputMethod(observation("other")) { execution -> + executions += execution + replay(fixture, execution) + } + + assertEquals(CallsMissingInputMethodVerdict.NO_MATCHING_ORIGINAL_ERROR, result.verdict) + assertNull(result.alternative) + assertEquals(listOf(CallsMissingInputMethodExecution(listOf("service", "other"), install = false)), executions) + } + + @Test + fun `records unhandled rejections after an alternative returns`() { + val fixture = fixture("invokeWithRejection") + + val result = replayMissingInputMethod(observation("missing")) { execution -> + replay(fixture, execution) + } + + assertEquals(CallsMissingInputMethodVerdict.RETURNED_WITH_UNHANDLED_REJECTION, result.verdict, result.toString()) + val trace = assertNotNull(result.alternative?.trace) + assertEquals(1, trace.atCompletion.ownerCalls) + assertEquals( + listOf(CallsMissingInputMethodRejection("Error", "later", handledWithinWindow = false)), + trace.unhandledRejections, + ) + } + + private fun observation(method: String) = CallsMissingInputMethodObservation( + fields = listOf("service", method), + errorMessage = "this.service.$method is not a function", + ) + + private fun replay(candidate: CallsClassInputCandidate, execution: CallsMissingInputMethodExecution? = null) = + replayCallsSavedInput( + sourceRoot = directory, + sourceFile = sourceFile, + targetSignature = signature, + candidate = candidate, + timeoutMillis = 15_000, + missingMethod = execution, + ) + + private fun fixture(method: String): CallsClassInputCandidate { + val source = """ + export class Fixture { + service: any; + alias: any; + values: any[]; + invoke(): number { + if (this.service !== this.alias || 0 in this.values || !(1 in this.values)) throw Error("changed heap"); + const result = this.service.missing(); + return result === undefined ? 7 : -1; + } + invokeWithRejection(): number { + this.service.missing(); + Promise.reject(new Error("later")); + return 7; + } + } + """.trimIndent() + Files.writeString(directory.resolve(sourceFile), source) + val methodSignature = "Fixture::$method(): number" + val service = CallsConcreteHeapValue(objectId = 1) + val receiver = CallsConcreteHeapObject( + id = 0, + classSignature = signature, + classSourceFile = sourceFile, + className = "Fixture", + fields = mapOf("service" to service, "alias" to service, "values" to CallsConcreteHeapValue(objectId = 2)), + ) + val array = CallsConcreteHeapObject( + id = 2, elements = listOf(null, CallsConcreteHeapValue(primitive = JsConcreteValue.Undefined)), + ) + val heap = CallsConcreteHeap( + receiver = CallsConcreteHeapValue(objectId = 0), + arguments = emptyList(), + objects = listOf(receiver, CallsConcreteHeapObject(id = 1, fields = emptyMap()), array), + ) + return CallsClassInputCandidate( + stateId = "fixture", + entryMethod = methodSignature, + currentMethod = methodSignature, + statementIndex = 0, + className = "Fixture", + methodName = method, + invocationKind = CallsClassInvocationKind.INSTANCE_METHOD, + outcome = "RETURNED", + profile = CallsExperimentProfile.EMPTY_FRESH, + origin = CallsCoverageCandidateOrigin.TERMINATED, + completion = CallsCoverageCompletion.RETURNED, + suspensionReason = null, + suspendedAtMachineStop = false, + emittedAtMillis = 0, + inputs = heap, + environmentComplete = true, + environmentLimitations = emptyList(), + ) + } + + private companion object { + const val sourceFile = "Fixture.ts" + val signature = EtsClassSignature( + name = "Fixture", + file = EtsFileSignature(projectName = "missing-method", fileName = sourceFile), + ).toString() + } +} From 92c2cde200d729f16eaa6cbed5e2ad21c4299a54 Mon Sep 17 00:00:00 2001 From: Aleksei Menshutin Date: Fri, 4 Dec 2026 06:24:37 +0100 Subject: [PATCH 2/2] Resolve Detekt findings in the missing input method experiment --- .../org/usvm/ts/calls/CallsClassOracle.kt | 4 +-- .../CallsMissingInputMethodExperiment.kt | 17 +++++++--- .../usvm/ts/calls/CallsSavedInputReplay.kt | 34 ++++++++++++------- .../CallsMissingInputMethodExperimentTest.kt | 12 +++++-- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsClassOracle.kt b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsClassOracle.kt index 1bc9c50a33..71978062ae 100644 --- a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsClassOracle.kt +++ b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsClassOracle.kt @@ -25,8 +25,8 @@ import org.usvm.ts.pbt.fastcheck.FastCheckRuntime import org.usvm.ts.pbt.fastcheck.TypeScriptLocalSourceClosure import org.usvm.ts.pbt.model.ArrayDomain import org.usvm.ts.pbt.model.BooleanDomain -import org.usvm.ts.pbt.model.ExecutionKind import org.usvm.ts.pbt.model.ConstantDomain +import org.usvm.ts.pbt.model.ExecutionKind import org.usvm.ts.pbt.model.IntegerDomain import org.usvm.ts.pbt.model.JsConcreteValue import org.usvm.ts.pbt.model.NumberDomain @@ -449,7 +449,7 @@ ${classReplayThrownValueDiagnosticSource().prependIndent(indent = " ")} let returned: any; let completion = 'RETURNED'; try { - returned = ${await}(scenarioModule as any)[$exportKey](...actualArgs$promiseCheckArgument); + returned = $await(scenarioModule as any)[$exportKey](...actualArgs$promiseCheckArgument); } catch (error) { completion = 'THREW'; const isShapeFailure = error instanceof Error && error.message.startsWith('USVM class observation shape:'); diff --git a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperiment.kt b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperiment.kt index 2d63556721..f1cbbc731e 100644 --- a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperiment.kt +++ b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperiment.kt @@ -53,7 +53,10 @@ internal data class CallsMissingInputMethodRun( val replay: CallsSavedInputReplayResult, val trace: CallsMissingInputMethodTrace?, ) { - fun text(name: String): String? = (replay.observation?.observation?.values?.get(name) as? JsConcreteValue.String)?.value + fun text(name: String): String? { + val value = replay.observation?.observation?.values?.get(name) + return (value as? JsConcreteValue.String)?.value + } } @Serializable @@ -85,7 +88,9 @@ internal fun replayMissingInputMethod( val originalTrace = original.trace if (originalTrace == null) { return CallsMissingInputMethodResult( - original, alternative = null, verdict = CallsMissingInputMethodVerdict.ORIGINAL_UNAVAILABLE, + original = original, + alternative = null, + verdict = CallsMissingInputMethodVerdict.ORIGINAL_UNAVAILABLE, ) } @@ -93,12 +98,16 @@ internal fun replayMissingInputMethod( original.text("diagnostic") == "TypeError: ${observation.errorMessage}" if (!matchesOriginal) { return CallsMissingInputMethodResult( - original, alternative = null, verdict = CallsMissingInputMethodVerdict.NO_MATCHING_ORIGINAL_ERROR, + original = original, + alternative = null, + verdict = CallsMissingInputMethodVerdict.NO_MATCHING_ORIGINAL_ERROR, ) } if (originalTrace.atCompletion.status != "ELIGIBLE") { return CallsMissingInputMethodResult( - original, alternative = null, verdict = CallsMissingInputMethodVerdict.OWNER_INELIGIBLE, + original = original, + alternative = null, + verdict = CallsMissingInputMethodVerdict.OWNER_INELIGIBLE, ) } diff --git a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsSavedInputReplay.kt b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsSavedInputReplay.kt index 29b7ac4701..cdf683ecea 100644 --- a/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsSavedInputReplay.kt +++ b/usvm-ts-calls/src/main/kotlin/org/usvm/ts/calls/CallsSavedInputReplay.kt @@ -9,6 +9,7 @@ import org.usvm.ts.pbt.fastcheck.TypeScriptSavedInputBindings import org.usvm.ts.pbt.fastcheck.TypeScriptSavedInputClass import org.usvm.ts.pbt.fastcheck.TypeScriptSourceInspector import org.usvm.ts.pbt.model.BooleanDomain +import org.usvm.ts.pbt.model.PropertyDomain import org.usvm.ts.pbt.model.StringDomain import org.usvm.ts.pbt.model.TypeScriptEntryPoint import org.usvm.ts.pbt.model.encodeToUtf8SafeString @@ -41,7 +42,8 @@ internal fun runSavedInputReplay(args: List, experiment: Boolean = false val experimentArgument = if (experiment) " " else "" val expectedArguments = SAVED_INPUT_REPLAY_ARGUMENT_COUNT + if (experiment) 1 else 0 require(args.size == expectedArguments) { - "$command needs $experimentArgument " + val inputs = " " + "$command needs $inputs$experimentArgument " } val arguments = args.iterator() val manifestArgument = arguments.next() @@ -109,6 +111,7 @@ internal fun runSavedInputReplay(args: List, experiment: Boolean = false } /** Reuses the normal frozen-closure copier, supervised native process and class observation transport. */ +@Suppress("TooGenericExceptionCaught") internal fun replayCallsSavedInput( sourceRoot: Path, sourceFile: String, @@ -182,13 +185,7 @@ internal fun replayCallsSavedInput( inputs = emptyList(), targets = emptyList(), ) - val fields = buildMap { - put("completion", StringDomain()) - put("returnValue", StringDomain(maxLength = Int.MAX_VALUE)) - put("returnValueRepresentable", BooleanDomain) - put("diagnostic", StringDomain(maxLength = Int.MAX_VALUE)) - if (missingMethod != null) put("missingMethod", StringDomain(maxLength = Int.MAX_VALUE)) - } + val fields = savedInputObservationFields(includeMissingMethod = missingMethod != null) val preparedClosure = savedInputSourceClosure(root = workspace, sourceFile = harnessName) val preparedClosureResolved = preparedClosure.reasonCode == null && preparedClosure.resolution?.runtimeBoundaries.orEmpty().isEmpty() @@ -213,6 +210,7 @@ internal fun replayCallsSavedInput( sourceInitializationDiagnostics = closure.initializationIssues.map { it.diagnostic }, ) } catch (failure: Exception) { + // The experiment records harness failures as evidence. Ordinary replay propagates them to the caller. if (missingMethod == null) throw failure return CallsSavedInputReplayResult( @@ -225,6 +223,14 @@ internal fun replayCallsSavedInput( } } +private fun savedInputObservationFields(includeMissingMethod: Boolean): Map = buildMap { + put("completion", StringDomain()) + put("returnValue", StringDomain(maxLength = Int.MAX_VALUE)) + put("returnValueRepresentable", BooleanDomain) + put("diagnostic", StringDomain(maxLength = Int.MAX_VALUE)) + if (includeMissingMethod) put("missingMethod", StringDomain(maxLength = Int.MAX_VALUE)) +} + private fun savedInputSourceClosure(root: Path, sourceFile: String): TypeScriptLocalSourceClosure = TypeScriptSourceInspector.startupSourceClosure(sourceRoot = root, source = root.resolve(sourceFile)) @@ -351,10 +357,14 @@ private fun savedInputHarness( } val missingMethodSupport = if (missingMethod == null) "" else missingInputMethodSource() val promiseCheck = if (missingMethod == null) "" else "isPromise: (value: unknown) => boolean" - val runExperiment = if (missingMethod == null) "" else """ - candidate.structural = ${encodeCallsArtifact(missingMethod)}; - return observeMissingInputMethod(candidate, restored, () => $invocation, encode, isPromise); - """.trimIndent() + val runExperiment = if (missingMethod == null) { + "" + } else { + """ + candidate.structural = ${encodeCallsArtifact(missingMethod)}; + return observeMissingInputMethod(candidate, restored, () => $invocation, encode, isPromise); + """.trimIndent() + } return """ ${imports.joinToString("\n")} diff --git a/usvm-ts-calls/src/test/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperimentTest.kt b/usvm-ts-calls/src/test/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperimentTest.kt index 49cbfda808..ecb080b23d 100644 --- a/usvm-ts-calls/src/test/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperimentTest.kt +++ b/usvm-ts-calls/src/test/kotlin/org/usvm/ts/calls/CallsMissingInputMethodExperimentTest.kt @@ -44,8 +44,9 @@ class CallsMissingInputMethodExperimentTest { assertEquals(1, trace.atCompletion.ownerCalls) assertFalse(alternative.replay.nativeReplayValidated) assertFalse(alternative.replay.nativeCoverageAvailable) + val originalReplay = experiment.original.replay val originalValues = assertNotNull(ordinary.observation).observation.values - assertEquals(originalValues, experiment.original.replay.observation?.observation?.values) + assertEquals(originalValues, originalReplay.observation?.observation?.values) } @Test @@ -71,7 +72,11 @@ class CallsMissingInputMethodExperimentTest { replay(fixture, execution) } - assertEquals(CallsMissingInputMethodVerdict.RETURNED_WITH_UNHANDLED_REJECTION, result.verdict, result.toString()) + assertEquals( + CallsMissingInputMethodVerdict.RETURNED_WITH_UNHANDLED_REJECTION, + result.verdict, + result.toString(), + ) val trace = assertNotNull(result.alternative?.trace) assertEquals(1, trace.atCompletion.ownerCalls) assertEquals( @@ -124,7 +129,8 @@ class CallsMissingInputMethodExperimentTest { fields = mapOf("service" to service, "alias" to service, "values" to CallsConcreteHeapValue(objectId = 2)), ) val array = CallsConcreteHeapObject( - id = 2, elements = listOf(null, CallsConcreteHeapValue(primitive = JsConcreteValue.Undefined)), + id = 2, + elements = listOf(null, CallsConcreteHeapValue(primitive = JsConcreteValue.Undefined)), ) val heap = CallsConcreteHeap( receiver = CallsConcreteHeapValue(objectId = 0),