From a7cee4a8e4f1f75b217638cf9068de1d54145682 Mon Sep 17 00:00:00 2001 From: adybag14-cyber Date: Fri, 29 May 2026 06:39:42 +0100 Subject: [PATCH 1/3] test(zigux): add lane17 bench live patch applier proof --- ...7_phase1_bench_live_step_patch_applier.zig | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 zigux/tests/lane17_phase1_bench_live_step_patch_applier.zig diff --git a/zigux/tests/lane17_phase1_bench_live_step_patch_applier.zig b/zigux/tests/lane17_phase1_bench_live_step_patch_applier.zig new file mode 100644 index 00000000000000..c111efc35cd247 --- /dev/null +++ b/zigux/tests/lane17_phase1_bench_live_step_patch_applier.zig @@ -0,0 +1,116 @@ +const std = @import("std"); + +const bench_self_test_step = + " - name: Self-test current Phase 1 bench checker\n" ++ + " run: python3 scripts/zigux/check-phase1-bench.py --self-test"; + +const bench_live_check_step = + " - name: Check current Phase 1 bench packet\n" ++ + " run: python3 scripts/zigux/check-phase1-bench.py"; + +const find_bit_bench_self_test_step = + " - name: Self-test current Phase 1 find-bit bench anchor checker\n" ++ + " run: python3 scripts/zigux/check-phase1-find-bit-bench-anchors.py --self-test"; + +const find_bit_bench_live_check_step = + " - name: Check current Phase 1 find-bit bench anchor packet\n" ++ + " run: python3 scripts/zigux/check-phase1-find-bit-bench-anchors.py"; + +const current_missing_handoff = + bench_self_test_step ++ + "\n\n" ++ + find_bit_bench_self_test_step ++ + "\n\n" ++ + find_bit_bench_live_check_step ++ + "\n"; + +const expected_patched_handoff = + bench_self_test_step ++ + "\n\n" ++ + bench_live_check_step ++ + "\n\n" ++ + find_bit_bench_self_test_step ++ + "\n\n" ++ + find_bit_bench_live_check_step ++ + "\n"; + +fn countMarkers(haystack: []const u8, needle: []const u8) usize { + var count: usize = 0; + var offset: usize = 0; + while (std.mem.indexOfPos(u8, haystack, offset, needle)) |index| { + count += 1; + offset = index + needle.len; + } + return count; +} + +fn singleMarkerOffset(haystack: []const u8, needle: []const u8) !usize { + const first = std.mem.indexOf(u8, haystack, needle) orelse return error.MissingWorkflowMarker; + if (std.mem.indexOfPos(u8, haystack, first + needle.len, needle) != null) { + return error.DuplicateWorkflowMarker; + } + return first; +} + +fn appendWithBenchLiveCheck(allocator: std.mem.Allocator, workflow: []const u8) ![]u8 { + const bench_self_test = try singleMarkerOffset(workflow, bench_self_test_step); + const find_bit_self_test = try singleMarkerOffset(workflow, find_bit_bench_self_test_step); + + if (countMarkers(workflow, bench_live_check_step) != 0) { + return error.LiveBenchCheckAlreadyPresent; + } + if (bench_self_test >= find_bit_self_test) { + return error.WorkflowMarkerOutOfOrder; + } + + const insert_at = bench_self_test + bench_self_test_step.len; + return std.mem.concat(allocator, u8, &.{ + workflow[0..insert_at], + "\n\n", + bench_live_check_step, + workflow[insert_at..], + }); +} + +test "lane17 bench live patch applier inserts the exact workflow step" { + const patched = try appendWithBenchLiveCheck(std.testing.allocator, current_missing_handoff); + defer std.testing.allocator.free(patched); + + try std.testing.expectEqualStrings(expected_patched_handoff, patched); + try std.testing.expectEqual(@as(usize, 1), countMarkers(patched, bench_live_check_step)); +} + +test "lane17 bench live patch applier rejects duplicate application" { + try std.testing.expectError( + error.LiveBenchCheckAlreadyPresent, + appendWithBenchLiveCheck(std.testing.allocator, expected_patched_handoff), + ); +} + +test "lane17 bench live patch applier rejects missing anchors" { + const missing_bench_self_test = + find_bit_bench_self_test_step ++ + "\n\n" ++ + find_bit_bench_live_check_step ++ + "\n"; + + try std.testing.expectError( + error.MissingWorkflowMarker, + appendWithBenchLiveCheck(std.testing.allocator, missing_bench_self_test), + ); +} + +test "lane17 bench live patch applier rejects reordered anchors" { + const reordered_handoff = + find_bit_bench_self_test_step ++ + "\n\n" ++ + bench_self_test_step ++ + "\n\n" ++ + find_bit_bench_live_check_step ++ + "\n"; + + try std.testing.expectError( + error.WorkflowMarkerOutOfOrder, + appendWithBenchLiveCheck(std.testing.allocator, reordered_handoff), + ); +} From f5a670724f65a3bb5d7c4a361693383e35548451 Mon Sep 17 00:00:00 2001 From: adybag14-cyber Date: Fri, 29 May 2026 07:37:59 +0100 Subject: [PATCH 2/3] test(zigux): add lane17 bench patch applier build route --- ...e1_bench_live_step_patch_applier_build.zig | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 zigux/tests/lane17_phase1_bench_live_step_patch_applier_build.zig diff --git a/zigux/tests/lane17_phase1_bench_live_step_patch_applier_build.zig b/zigux/tests/lane17_phase1_bench_live_step_patch_applier_build.zig new file mode 100644 index 00000000000000..29f58bc08f1ac7 --- /dev/null +++ b/zigux/tests/lane17_phase1_bench_live_step_patch_applier_build.zig @@ -0,0 +1,22 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const tests = b.addTest(.{ + .root_module = b.createModule(.{ + .root_source_file = b.path("lane17_phase1_bench_live_step_patch_applier.zig"), + .target = target, + .optimize = optimize, + }), + }); + + const run_tests = b.addRunArtifact(tests); + const test_step = b.step( + "lane17-phase1-bench-live-step-patch-applier", + "Run the Lane 17 Phase 1 bench live-step patch-applier proof", + ); + test_step.dependOn(&run_tests.step); + b.default_step.dependOn(test_step); +} From 9aa522b6a6f2d7cc856b209df4b80a94adedb1b7 Mon Sep 17 00:00:00 2001 From: adybag14-cyber Date: Fri, 29 May 2026 11:38:23 +0100 Subject: [PATCH 3/3] test(zigux): add lane17 patch applier test alias --- ...e17_phase1_bench_live_step_patch_applier_build.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/zigux/tests/lane17_phase1_bench_live_step_patch_applier_build.zig b/zigux/tests/lane17_phase1_bench_live_step_patch_applier_build.zig index 29f58bc08f1ac7..fa43f11b3fe71f 100644 --- a/zigux/tests/lane17_phase1_bench_live_step_patch_applier_build.zig +++ b/zigux/tests/lane17_phase1_bench_live_step_patch_applier_build.zig @@ -13,10 +13,17 @@ pub fn build(b: *std.Build) void { }); const run_tests = b.addRunArtifact(tests); - const test_step = b.step( + const named_step = b.step( "lane17-phase1-bench-live-step-patch-applier", "Run the Lane 17 Phase 1 bench live-step patch-applier proof", ); + named_step.dependOn(&run_tests.step); + + const test_step = b.step( + "test", + "Run the Lane 17 Phase 1 bench live-step patch-applier proof", + ); test_step.dependOn(&run_tests.step); - b.default_step.dependOn(test_step); + + b.default_step.dependOn(named_step); }