#include "../../experiments/frontend/gcc-worker/Trace.hpp" #include #include #include #include #include #include #include #include #include #include #include #include namespace { namespace fs = std::filesystem; namespace protocol = Void::LanguageServer::Protocol; using protocol::Json; using vls::gcc::replay; using vls::gcc::Trace; using Void::Testing::expect; using Void::Testing::expect_eq; using Void::Testing::require; using namespace std::string_view_literals; constexpr auto nonce = "00112233445566778899aabbccddeeff"sv; constexpr auto digest = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"sv; constexpr auto source_17 = "int answer = 17;\n"sv; constexpr std::int64_t pid = 4321; // Exact field shapes from the accepted GCC evaluator witness. These tests never start a compiler. constexpr auto hello = R"({"v":1,"nonce":"00112233445566778899aabbccddeeff","seq":0,"kind":"hello","backend":"gcc-16.2.0/vls-eval-1","pid":4321,"capabilities":["integralReturn","cooperativeStep"],"kinds":["hello","enter","body","value","cached","stopped","resumed","leave","terminal","frontendEnd"]})"sv; constexpr auto no_source = R"(,"sourceKind":"unavailable")"sv; constexpr auto value_17 = R"(,"value":{"kind":"integer","precision":32,"signed":true,"bitsHex":"00000011"})"sv; constexpr auto value_34 = R"(,"value":{"kind":"integer","precision":32,"signed":true,"bitsHex":"00000022"})"sv; constexpr auto unavailable = R"(,"value":{"kind":"unavailable","reason":"unsupportedScalar"})"sv; struct Fixture { Void::FileSystem::TempDir directory{"vls_trace_"}; fs::path journal = directory / "trace"; std::unique_ptr create(std::string_view source = source_17) const { auto trace = Trace::create(journal, source, digest, nonce, pid); require(trace.has_value()); return std::move(*trace); } }; const Json &field(const Json &json, std::string_view key) { const auto *object = protocol::as_object(&json); require(object != nullptr); const auto *value = protocol::find_member(*object, key); require(value != nullptr); return *value; } std::string_view text(const Json &json, std::string_view key) { const auto *value = protocol::as_string(&field(json, key)); require(value != nullptr); return *value; } std::int64_t number(const Json &json, std::string_view key) { const auto *value = std::get_if(&field(json, key).value); require(value != nullptr); return *value; } bool flag(const Json &json, std::string_view key) { return std::get(field(json, key).value); } bool null(const Json &json, std::string_view key) { return std::holds_alternative(field(json, key).value); } const Json::Array &frames(const Json &json) { return std::get(field(json, "frames").value); } std::string_view bits(const Json &frame) { return text(field(frame, "value"), "bitsHex"); } std::string wire(std::uint32_t seq, std::string_view kind, std::string_view members = {}) { return std::format(R"({{"v":1,"nonce":"{}","seq":{},"kind":"{}"{}}})", nonce, seq, kind, members); } std::string frame(std::uint32_t seq, std::string_view kind, std::uint32_t id, std::string_view parent, std::string_view members = {}) { return wire(seq, kind, std::format(R"(,"frame":{},"parent":{}{})", id, parent, members)); } std::string enter(std::uint32_t seq, std::string_view parent, std::string_view name) { return frame(seq, "enter", seq, parent, std::format(R"(,"name":{}{})", name, no_source)); } std::string replaced(std::string_view original, std::string_view before, std::string_view after) { std::string changed{original}; const auto offset = changed.find(before); require(offset != changed.npos); changed.replace(offset, before.size(), after); return changed; } void add(Trace &trace, std::string_view line, std::source_location at = std::source_location::current()) { const auto result = trace.event(line); expect_eq(result ? ""sv : std::string_view{result.error()}, ""sv, at); require(result.has_value(), at); } Json read(const fs::path &path, std::optional seq = std::nullopt, std::source_location at = std::source_location::current()) { auto result = replay(path, seq); expect_eq(result ? ""sv : std::string_view{result.error()}, ""sv, at); require(result.has_value(), at); return std::move(*result); } void put_file(const fs::path &path, std::string_view data, std::ios::openmode mode = std::ios::trunc) { std::ofstream file(path, std::ios::binary | mode); file.write(data.data(), static_cast(data.size())); file.close(); require(file.good()); } std::string file_bytes(const fs::path &path) { std::ifstream file(path, std::ios::binary); require(file.good()); return {std::istreambuf_iterator{file}, std::istreambuf_iterator{}}; } void first_stop(Trace &trace) { add(trace, hello); add(trace, enter(1, "null", R"("twice")")); add(trace, frame(2, "body", 1, "null")); add(trace, frame( 3, "enter", 3, "1", R"(,"name":"reflected_value","sourceKind":"logicalDeclaration","source":"input.cpp","line":5,"byteColumn":15)")); add(trace, frame(4, "body", 3, "1")); add(trace, frame(5, "value", 3, "1", value_17)); add(trace, frame(6, "stopped", 3, "1")); } } // namespace VOID_TEST(TraceTests, strict_handshake_and_envelope_reject_without_advancing) { const Fixture fixture; const auto trace = fixture.create(); const auto initial_bytes = fs::file_size(fixture.journal); expect(null(trace->inspection(), "sequence")); expect(!trace->event(wire(0, "frontendEnd"))); expect(!trace->event(replaced(hello, nonce, "10112233445566778899aabbccddeeff"))); expect(!trace->event(replaced(hello, "4321", "4322"))); expect(!trace->event(replaced(hello, "4321", "4321.0"))); expect(!trace->event(replaced(hello, "vls-eval-1", "vls-ide-1"))); expect(!trace->event(replaced(hello, "cooperativeStep", "integralReturn"))); expect(!trace->event(replaced(hello, R"("frontendEnd"])", R"("terminal"])"))); expect(!trace->event(replaced(hello, R"("v":1)", R"("v":1.00000000000000001)"))); expect(!trace->event(replaced(hello, R"("seq":0)", R"("seq":0,"seq":0)"))); expect(!trace->event(std::string{hello} + '\n')); expect_eq(fs::file_size(fixture.journal), initial_bytes); add(*trace, hello); expect(!trace->event(wire(2, "frontendEnd"))); expect(!trace->event(replaced(wire(1, "frontendEnd"), R"("seq":1)", R"("seq":1e0)"))); expect(!trace->event(hello)); expect_eq(number(read(fixture.journal), "sequence"), std::int64_t{0}); add(*trace, wire(1, "frontendEnd")); expect(!trace->event(wire(2, "frontendEnd"))); } VOID_TEST(TraceTests, frame_identity_parent_and_actual_body_are_required) { const Fixture fixture; const auto trace = fixture.create(); add(*trace, hello); expect( !trace->event(frame(1, "enter", 2, "null", R"(,"name":null,"sourceKind":"unavailable")"))); expect(!trace->event(enter(1, "0", "null"))); expect(!trace->event(enter(1, "null", R"("\u0001")"))); add(*trace, enter(1, "null", "null")); expect(!trace->event(wire(2, "body", R"(,"frame":1)"))); expect(!trace->event(wire(2, "frontendEnd"))); expect(!trace->event(frame(2, "value", 1, "null", value_17))); // GCC can enter a child during parameter work or lazy instantiation before the parent's body. add(*trace, enter(2, "1", R"("nested")")); expect(!trace->event(frame(3, "cached", 2, "null"))); expect(!trace->event(frame(3, "body", 1, "null"))); add(*trace, frame(3, "cached", 2, "1")); expect(!trace->event(frame(4, "value", 2, "1", value_17))); expect(!trace->event(frame(4, "body", 2, "1"))); add(*trace, frame(4, "leave", 2, "1", R"(,"outcome":"returned")")); const auto cached = read(fixture.journal, 4); expect(flag(field(cached, "lastLeave"), "cached")); expect(protocol::find_member(*protocol::as_object(&field(cached, "lastLeave")), "value") == nullptr); expect(!trace->event(frame(5, "enter", 2, "1", R"(,"name":null,"sourceKind":"unavailable")"))); add(*trace, frame(5, "leave", 1, "null", R"(,"outcome":"failed")")); add(*trace, wire(6, "frontendEnd")); expect(trace->ended()); } VOID_TEST(TraceTests, integer_width_and_unavailable_scalar_are_exact) { const Fixture fixture; const auto trace = fixture.create(); add(*trace, hello); add(*trace, enter(1, "null", R"("scalar")")); add(*trace, frame(2, "body", 1, "null")); for ( const auto malformed : { R"(,"value":{"kind":"integer","precision":0,"signed":true,"bitsHex":""})"sv, R"(,"value":{"kind":"integer","precision":65,"signed":true,"bitsHex":"00000000000000000"})"sv, R"(,"value":{"kind":"integer","precision":8.0,"signed":true,"bitsHex":"fd"})"sv, R"(,"value":{"kind":"integer","precision":8,"signed":true,"bitsHex":"f"})"sv, R"(,"value":{"kind":"integer","precision":8,"signed":true,"bitsHex":"FF"})"sv, R"(,"value":{"kind":"integer","precision":8,"signed":1,"bitsHex":"fd"})"sv, R"(,"value":{"kind":"integer","precision":1,"signed":false,"bitsHex":"2"})"sv, R"(,"value":{"kind":"unavailable","reason":"other"})"sv, }) { expect(!trace->event(frame(3, "value", 1, "null", malformed))); } add(*trace, frame( 3, "value", 1, "null", R"(,"value":{"kind":"integer","precision":64,"signed":false,"bitsHex":"8000000000000005"})")); const auto copied = read(fixture.journal, 3); expect_eq(bits(frames(copied).back()), "8000000000000005"sv); expect(!flag(field(frames(copied).back(), "value"), "signed")); add(*trace, frame(4, "leave", 1, "null", R"(,"outcome":"returned")")); add(*trace, enter(5, "null", R"("wide")")); add(*trace, frame(6, "body", 5, "null")); add(*trace, frame(7, "value", 5, "null", unavailable)); expect(!trace->event(frame(8, "stopped", 5, "null"))); const auto absent = read(fixture.journal, 7); expect_eq(text(field(frames(absent).back(), "value"), "reason"), "unsupportedScalar"sv); } VOID_TEST(TraceTests, steps_through_nested_values_and_seeks_before_the_command) { const Fixture fixture; const auto trace = fixture.create(); first_stop(*trace); expect_eq(trace->stopped(), std::optional{6}); expect(!trace->authorize(5, "step")); expect(!trace->authorize(7, "continue")); expect(!trace->authorize(6, "inspect")); expect(!trace->event(frame(7, "resumed", 3, "1", R"(,"stop":6,"action":"step")"))); require(trace->authorize(6, "step").has_value()); expect(!trace->stopped()); expect(!trace->authorize(6, "cancel")); const auto pending = read(fixture.journal); expect(null(pending, "stop")); expect_eq(text(pending, "pendingAction"), "step"sv); expect(!trace->event(frame(7, "leave", 3, "1", R"(,"outcome":"returned")"))); expect(!trace->event(frame(7, "resumed", 3, "1", R"(,"stop":6,"action":"continue")"))); expect(!trace->event(frame(7, "resumed", 3, "1", R"(,"stop":5,"action":"step")"))); add(*trace, frame(7, "resumed", 3, "1", R"(,"stop":6,"action":"step")")); add(*trace, frame(8, "leave", 3, "1", R"(,"outcome":"returned")")); add(*trace, frame(9, "value", 1, "null", value_34)); add(*trace, frame(10, "stopped", 1, "null")); expect(!trace->authorize(6, "continue")); require(trace->authorize(10, "continue").has_value()); add(*trace, frame(11, "resumed", 1, "null", R"(,"stop":10,"action":"continue")")); add(*trace, frame(12, "leave", 1, "null", R"(,"outcome":"returned")")); add(*trace, enter(13, "null", R"("another")")); add(*trace, frame(14, "body", 13, "null")); add(*trace, frame(15, "value", 13, "null", value_17)); expect(!trace->event(frame(16, "stopped", 13, "null"))); add(*trace, frame(16, "leave", 13, "null", R"(,"outcome":"returned")")); add(*trace, wire(17, "frontendEnd")); require(trace->finish("completed", 0, "").has_value()); const auto inner = read(fixture.journal, 6); require(frames(inner).size() == 2); expect_eq(text(frames(inner).front(), "name"), "twice"sv); expect_eq(text(frames(inner).back(), "name"), "reflected_value"sv); expect_eq(bits(frames(inner).back()), "00000011"sv); expect(flag(frames(inner).back(), "valueProvisional")); expect_eq(number(inner, "stop"), std::int64_t{6}); expect(null(inner, "pendingAction")); expect_eq(text(inner, "outcome"), "completed"sv); expect(!flag(inner, "frontendEnded")); expect(!flag(inner, "partial")); const auto after_leave = read(fixture.journal, 8); require(frames(after_leave).size() == 1); expect(!flag(field(after_leave, "lastLeave"), "valueProvisional")); expect_eq(bits(field(after_leave, "lastLeave")), "00000011"sv); const auto outer = read(fixture.journal, 10); require(frames(outer).size() == 1); expect_eq(number(outer, "stop"), std::int64_t{10}); expect_eq(bits(frames(outer).back()), "00000022"sv); const auto final = read(fixture.journal); expect(flag(final, "frontendEnded")); expect(frames(final).empty()); expect(!replay(fixture.journal, 18)); } VOID_TEST(TraceTests, cancellation_keeps_the_open_provisional_frame) { const Fixture fixture; auto trace = fixture.create(); first_stop(*trace); const auto cancelled = wire(7, "terminal", R"(,"reason":"cancelled","stop":6)"); expect(!trace->event(cancelled)); require(trace->authorize(6, "cancel").has_value()); expect(!trace->event(frame(7, "resumed", 3, "1", R"(,"stop":6,"action":"cancel")"))); expect(!trace->event(wire(7, "terminal", R"(,"reason":"cancelled","stop":5)"))); add(*trace, cancelled); expect_eq(trace->terminal(), "cancelled"sv); expect(!trace->stopped()); expect(!trace->ended()); expect(!trace->finish("completed", 0, "")); require(trace->finish("cancelled", 125, "").has_value()); trace.reset(); const auto recorded = read(fixture.journal); require(frames(recorded).size() == 2); expect_eq(bits(frames(recorded).back()), "00000011"sv); expect(flag(frames(recorded).back(), "valueProvisional")); expect(protocol::find_member(*protocol::as_object(&frames(recorded).front()), "value") == nullptr); expect(flag(recorded, "partial")); expect(!flag(recorded, "corrupt")); expect_eq(text(recorded, "outcome"), "cancelled"sv); expect_eq(number(recorded, "exitCode"), std::int64_t{125}); expect_eq(number(read(fixture.journal, 6), "stop"), std::int64_t{6}); } VOID_TEST(TraceTests, frontend_end_and_provisional_value_do_not_prove_success) { const Fixture fixture; const auto trace = fixture.create(); add(*trace, hello); add(*trace, enter(1, "null", R"("candidate")")); add(*trace, frame(2, "body", 1, "null")); add(*trace, frame(3, "value", 1, "null", replaced(value_17, "00000011", "00000009"))); add(*trace, frame(4, "leave", 1, "null", R"(,"outcome":"failed")")); expect(!trace->finish("completed", 0, "")); add(*trace, wire(5, "frontendEnd")); expect(!trace->finish("completed", 1, "unmatched")); expect(!trace->finish("another", 1, "unknown")); const auto before_wait = read(fixture.journal); expect(flag(before_wait, "frontendEnded")); expect(flag(before_wait, "partial")); expect(null(before_wait, "outcome")); require(trace->finish("failed", 1, "cleanup failed\n").has_value()); expect(!trace->finish("completed", 0, "")); const auto recorded = read(fixture.journal); expect(frames(recorded).empty()); const auto &leave = field(recorded, "lastLeave"); expect_eq(text(leave, "outcome"), "failed"sv); expect_eq(bits(leave), "00000009"sv); expect(flag(leave, "valueProvisional")); expect_eq(text(recorded, "outcome"), "failed"sv); expect_eq(text(recorded, "diagnostics"), "cleanup failed\n"sv); expect(!flag(recorded, "partial")); } VOID_TEST(TraceTests, replay_keeps_source_bytes_after_edit_and_removal) { const Fixture fixture; const auto original = fixture.directory / "input.cpp"; put_file(original, source_17); auto trace = fixture.create(file_bytes(original)); first_stop(*trace); trace.reset(); put_file(original, "int answer = 41;\n"); const auto edited = read(fixture.journal); expect_eq(text(edited, "source"), source_17); expect_eq(text(edited, "sourceSha256"), "e2727305e817a0da9431b286b4317caec93433b6bc372f242b2786944c60c28f"sv); expect_eq(text(edited, "compilerSha256"), digest); expect_eq(bits(frames(edited).back()), "00000011"sv); require(fs::remove(original)); const auto journal_before = file_bytes(fixture.journal); require(::chmod(fixture.journal.c_str(), 0400) == 0); const auto removed = read(fixture.journal, 6); expect_eq(text(removed, "source"), source_17); expect_eq(text(frames(removed).back(), "source"), "input.cpp"sv); expect(null(removed, "outcome")); expect(flag(removed, "partial")); expect_eq(file_bytes(fixture.journal), journal_before); } VOID_TEST(TraceTests, captured_binary_bytes_round_trip_in_json_projection) { const Fixture fixture; const auto trace = fixture.create("\xff\0x"sv); require(trace->finish("failed", 126, "\x80\n"sv).has_value()); const auto recorded = read(fixture.journal); expect(null(recorded, "source")); expect_eq(text(recorded, "sourceHex"), "ff0078"sv); expect_eq(text(recorded, "sourceSha256"), "b56ed79fd4921608ee3cc257a4bb1a7b726bf67c84a26f3e3ca41aa42c6e9737"sv); expect(null(recorded, "diagnostics")); expect_eq(text(recorded, "diagnosticsHex"), "800a"sv); expect(protocol::serialize_json(recorded).has_value()); } VOID_TEST(TraceTests, replay_recovers_verified_prefix_on_truncation_or_tampering) { const Fixture fixture; auto trace = fixture.create(); first_stop(*trace); require(trace->authorize(6, "cancel").has_value()); add(*trace, wire(7, "terminal", R"(,"reason":"cancelled","stop":6)")); require(trace->finish("cancelled", 125, "finished").has_value()); trace.reset(); const auto full = file_bytes(fixture.journal); fs::resize_file(fixture.journal, full.size() - 3); const auto torn = read(fixture.journal); expect_eq(number(torn, "sequence"), std::int64_t{7}); expect_eq(text(torn, "terminal"), "cancelled"sv); expect(null(torn, "outcome")); expect(flag(torn, "partial")); expect(!flag(torn, "corrupt")); put_file(fixture.journal, replaced(full, "reflected_value", "reflected_FAKE!")); const auto tampered = read(fixture.journal); expect_eq(number(tampered, "sequence"), std::int64_t{2}); require(frames(tampered).size() == 1); expect_eq(text(frames(tampered).front(), "name"), "twice"sv); expect(null(tampered, "outcome")); expect(flag(tampered, "partial")); expect(flag(tampered, "corrupt")); expect(!replay(fixture.journal, 3)); expect(flag(read(fixture.journal, 0), "corrupt")); put_file(fixture.journal, replaced(full, source_17, "int answer = 41;\n")); expect(!replay(fixture.journal, std::nullopt)); put_file(fixture.journal, full + "tail"); const auto after_finish = read(fixture.journal); expect(flag(after_finish, "corrupt")); expect(null(after_finish, "outcome")); expect_eq(number(after_finish, "sequence"), std::int64_t{7}); } VOID_TEST(TraceTests, replay_bounds_corrupt_lengths_and_regular_file_inputs) { const Fixture fixture; auto trace = fixture.create(); add(*trace, hello); trace.reset(); put_file(fixture.journal, "E\x7f\xff\xff\xff"sv, std::ios::app); const auto huge_record = read(fixture.journal); expect(flag(huge_record, "corrupt")); expect_eq(number(huge_record, "sequence"), std::int64_t{0}); expect_eq(text(huge_record, "journalError"), "invalid trace journal record type or length"sv); expect(!replay(fixture.journal, 4096)); expect(!replay(fixture.directory.path(), std::nullopt)); const auto fifo = fixture.directory / "fifo"; require(::mkfifo(fifo.c_str(), 0600) == 0); expect(!replay(fifo, std::nullopt)); const auto alias = fixture.directory / "alias"; fs::create_symlink(fixture.journal, alias); expect(!replay(alias, std::nullopt)); } VOID_TEST(TraceTests, trace_and_record_byte_budgets_hold_at_the_boundary) { const Fixture fixture; const auto trace = fixture.create(); std::string oversized{hello}; oversized.resize(4096, ' '); expect(!trace->event(oversized)); expect(null(trace->inspection(), "sequence")); // 255 full records leave exactly 4096 bytes. Fit the final enter and terminal in that page. std::string padded{hello}; padded.resize(4095, ' '); add(*trace, padded); for (std::uint32_t seq = 1; seq < 255; seq += 2) { padded = enter(seq, "null", "null"); padded.resize(4095, ' '); add(*trace, padded); padded = frame(seq + 1, "leave", seq, "null", R"(,"outcome":"failed")"); padded.resize(4095, ' '); add(*trace, padded); } const auto terminal = wire(256, "terminal", R"(,"reason":"truncated")"); padded = enter(255, "null", "null"); padded.resize(4094 - terminal.size(), ' '); add(*trace, padded); expect(!trace->event(terminal + ' ')); // Its LF would be one byte over the budget. expect_eq(number(trace->inspection(), "sequence"), std::int64_t{255}); add(*trace, terminal); expect(!trace->ended()); require(trace->finish("truncated", 126, "").has_value()); const auto limited = read(fixture.journal); expect_eq(text(limited, "outcome"), "truncated"sv); expect(flag(limited, "partial")); } VOID_TEST(TraceTests, compiler_truncation_without_stop_token_is_valid) { const Fixture fixture; const auto trace = fixture.create(); first_stop(*trace); require(trace->authorize(6, "step").has_value()); expect(!trace->event(wire(7, "terminal", R"(,"reason":"truncated","stop":6)"))); add(*trace, wire(7, "terminal", R"(,"reason":"truncated")")); expect_eq(trace->terminal(), "truncated"sv); expect(!trace->stopped()); expect(!trace->ended()); const auto recorded = read(fixture.journal); expect(flag(recorded, "partial")); expect(!flag(recorded, "corrupt")); expect_eq(bits(frames(recorded).back()), "00000011"sv); } VOID_TEST(TraceTests, journal_creation_and_stop_authorization_are_exclusive) { const Fixture fixture; expect(!Trace::create(fixture.journal, source_17, digest, "incorrect", pid)); expect(!Trace::create(fixture.journal, source_17, digest, nonce, 0)); expect(!Trace::create(fixture.journal, std::string(1024 * 1024 + 1, 'x'), digest, nonce, pid)); expect(fs::is_empty(fixture.directory.path())); std::array, 2> recorders; std::barrier start(2); const auto attempt = [&](std::size_t index) { start.arrive_and_wait(); auto created = Trace::create(fixture.journal, source_17, digest, nonce, pid); if (created) { recorders[index] = std::move(*created); } }; std::jthread first(attempt, 0); attempt(1); first.join(); require(static_cast(recorders[0]) != static_cast(recorders[1])); auto &trace = recorders[recorders[0] ? 0 : 1]; struct stat status{}; require(::stat(fixture.journal.c_str(), &status) == 0); expect((status.st_mode & 0777) == 0600); first_stop(*trace); std::array accepted{}; const auto race = [&](std::size_t index) { start.arrive_and_wait(); accepted[index] = trace->authorize(6, "step").has_value(); }; std::jthread second(race, 0); race(1); second.join(); expect(accepted[0] != accepted[1]); expect(!trace->stopped()); const auto saved = file_bytes(fixture.journal); expect(!Trace::create(fixture.journal, "new source", digest, nonce, pid)); expect_eq(file_bytes(fixture.journal), saved); expect(static_cast(std::distance(fs::directory_iterator{fixture.directory.path()}, fs::directory_iterator{})) == 1); } VOID_TEST(TraceTests, splice_origin_is_declared_validated_and_exposed) { constexpr auto origin = R"(,"source":"input.cpp","line":4,"byteColumn":31,"targetKind":"declaration","targetName":"Ready","targetSource":"input.cpp","targetLine":1,"targetByteColumn":20)"sv; const Fixture legacy; const auto old_trace = legacy.create(); add(*old_trace, hello); expect(!old_trace->event(wire(1, "splice", origin))); const Fixture current; const auto trace = current.create(); add(*trace, replaced(hello, R"("frontendEnd"])", R"("frontendEnd","splice"])")); expect(!trace->event(wire(1, "splice", replaced(origin, R"("line":4)", R"("line":0)")))); expect(!trace->event( wire(1, "splice", replaced(origin, R"("targetKind":"declaration")", R"("targetKind":"alias")")))); expect(!trace->event( wire(1, "splice", replaced(origin, R"("targetLine":1)", R"("targetLine":null)")))); add(*trace, wire(1, "splice", origin)); const auto inspection = trace->inspection(); const auto *origins = protocol::as_array(protocol::find_member(*protocol::as_object(&inspection), "origins")); require(origins != nullptr && origins->size() == 1); expect(number(origins->front(), "line") == 4); expect(text(origins->front(), "targetName") == "Ready"); expect(number(origins->front(), "targetByteColumn") == 20); }