@native-sdk/cli 0.4.4 → 0.5.1
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/build/app.zig +371 -5
- package/build/ts_run.mjs +102 -0
- package/build.zig +255 -1
- package/build.zig.zon +1 -0
- package/package.json +19 -10
- package/packages/core/package-lock.json +44 -0
- package/packages/core/package.json +38 -0
- package/packages/core/rt/rt.zig +1579 -0
- package/packages/core/sdk/bytes_text_methods.d.ts +88 -0
- package/packages/core/sdk/core.ts +694 -0
- package/packages/core/sdk/events.ts +137 -0
- package/packages/core/sdk/text.ts +519 -0
- package/packages/core/src/checker.ts +1869 -0
- package/packages/core/src/cli.ts +68 -0
- package/packages/core/src/devhost.ts +291 -0
- package/packages/core/src/devhost_resolver.mjs +22 -0
- package/packages/core/src/diagnostics.ts +417 -0
- package/packages/core/src/emitter.ts +8815 -0
- package/packages/core/src/infer.ts +1515 -0
- package/packages/core/src/modules.ts +173 -0
- package/packages/core/src/ownership.ts +740 -0
- package/packages/core/src/text_polyfill.ts +337 -0
- package/packages/core/src/text_tables.ts +408 -0
- package/packages/core/src/transpile.ts +146 -0
- package/packages/core/src/typed_ast.ts +546 -0
- package/packages/core/src/types.ts +815 -0
- package/skill-data/native-ui/SKILL.md +14 -0
- package/skill-data/ts-core/SKILL.md +493 -0
- package/skill-data/zig/SKILL.md +10 -0
- package/src/app_runner/root.zig +24 -0
- package/src/app_runner/ts_core_main.zig +231 -0
- package/src/platform/windows/webview2_host.cpp +24 -0
- package/src/primitives/app_manifest/comptime_scene.zig +341 -0
- package/src/primitives/app_manifest/root.zig +5 -0
- package/src/primitives/canvas/commands.zig +14 -7
- package/src/primitives/canvas/layout_audit.zig +5 -5
- package/src/primitives/canvas/lazy_tls.zig +73 -0
- package/src/primitives/canvas/render_generic_resources.zig +22 -15
- package/src/primitives/canvas/root.zig +11 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +40 -32
- package/src/primitives/canvas/text_layout_cache.zig +29 -22
- package/src/primitives/canvas/text_measure_cache.zig +56 -41
- package/src/primitives/canvas/text_spans.zig +39 -26
- package/src/primitives/canvas/tokens.zig +69 -0
- package/src/primitives/canvas/ui.zig +125 -0
- package/src/primitives/canvas/ui_markup.zig +22 -3
- package/src/primitives/canvas/ui_markup_compiled.zig +97 -7
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +275 -0
- package/src/primitives/canvas/ui_markup_contract.zig +68 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +257 -2
- package/src/primitives/canvas/ui_markup_reflect.zig +214 -0
- package/src/primitives/canvas/ui_markup_view.zig +105 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +336 -0
- package/src/primitives/canvas/ui_schema.zig +8 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_builtin_tests.zig +309 -5
- package/src/primitives/canvas/widget_invalidation.zig +14 -7
- package/src/primitives/canvas/widget_layout.zig +138 -2
- package/src/primitives/canvas/widget_metrics.zig +16 -8
- package/src/primitives/canvas/widget_render.zig +25 -15
- package/src/primitives/canvas/widget_render_controls.zig +15 -9
- package/src/primitives/canvas/widget_runtime_tests.zig +44 -0
- package/src/root.zig +7 -0
- package/src/runtime/canvas_frame.zig +57 -36
- package/src/runtime/canvas_images.zig +9 -3
- package/src/runtime/canvas_widget_control_tests.zig +5 -6
- package/src/runtime/canvas_widget_runtime.zig +7 -4
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +1525 -133
- package/src/runtime/effects_fetch_tests.zig +42 -0
- package/src/runtime/effects_file_tests.zig +220 -0
- package/src/runtime/effects_host_tests.zig +594 -0
- package/src/runtime/effects_tests.zig +287 -0
- package/src/runtime/root.zig +18 -0
- package/src/runtime/session_replay.zig +7 -1
- package/src/runtime/tests.zig +2 -0
- package/src/runtime/ts_core_host.zig +1505 -0
- package/src/runtime/ts_core_host_tests.zig +1408 -0
- package/src/runtime/ts_ui_app.zig +469 -0
- package/src/runtime/ui_app.zig +189 -38
- package/src/runtime/ui_app_tests.zig +221 -0
- package/src/runtime/ui_app_window_tests.zig +182 -0
- package/src/runtime/view_canvas.zig +24 -17
- package/src/runtime/view_widget_tree.zig +2 -2
- package/src/tooling/codesign.zig +212 -105
- package/src/tooling/doctor.zig +78 -0
- package/src/tooling/manifest.zig +47 -0
- package/src/tooling/package.zig +435 -20
- package/src/tooling/raw_manifest.zig +15 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +777 -34
- package/src/tooling/ts_core.zig +1099 -0
- package/src/tooling/verbs.zig +105 -2
|
@@ -5,6 +5,7 @@ const app_manifest = @import("app_manifest");
|
|
|
5
5
|
const core = @import("core.zig");
|
|
6
6
|
const ui_app_model = @import("ui_app.zig");
|
|
7
7
|
const effects_mod = @import("effects.zig");
|
|
8
|
+
const clock_mod = @import("clock.zig");
|
|
8
9
|
const platform_mod = @import("../platform/root.zig");
|
|
9
10
|
|
|
10
11
|
const canvas_label = "stream-canvas";
|
|
@@ -864,6 +865,292 @@ test "real executor cancels a long-running stream cleanly" {
|
|
|
864
865
|
try std.testing.expectEqual(@as(usize, 0), h.app_state.effects.activeCount());
|
|
865
866
|
}
|
|
866
867
|
|
|
868
|
+
test "teardown mid-stream kills the real child and joins its worker before returning" {
|
|
869
|
+
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
|
870
|
+
var h = try Harness.create();
|
|
871
|
+
defer h.destroy();
|
|
872
|
+
|
|
873
|
+
// A child that would outlive the whole suite: only the teardown's
|
|
874
|
+
// kill can end it. Waiting for the first line proves the worker is
|
|
875
|
+
// mid-stream (child spawned, stdout pipe open) when deinit runs —
|
|
876
|
+
// the exact posture of the e2e battery's timed-out cancel test.
|
|
877
|
+
test_argv = &.{ "/bin/sh", "-c", "echo streaming; sleep 30" };
|
|
878
|
+
test_stdin = null;
|
|
879
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
880
|
+
try waitForRealCompletion(&h, sawLine);
|
|
881
|
+
|
|
882
|
+
const fx = &h.app_state.effects;
|
|
883
|
+
const start_ns = clock_mod.monotonicNanoseconds();
|
|
884
|
+
fx.deinit();
|
|
885
|
+
const elapsed_ms = (clock_mod.monotonicNanoseconds() - start_ns) / std.time.ns_per_ms;
|
|
886
|
+
|
|
887
|
+
// The kill ended the child — nothing waited out its 30s sleep
|
|
888
|
+
// (generous bound: a loaded runner still reaps a SIGKILLed child
|
|
889
|
+
// orders of magnitude faster than the sleep)...
|
|
890
|
+
try std.testing.expect(elapsed_ms < 10_000);
|
|
891
|
+
// ...and every worker was JOINED, not abandoned: no slot keeps a
|
|
892
|
+
// thread handle and none is still running, so the owner may free
|
|
893
|
+
// the channel's memory immediately. This pins the ownership hole
|
|
894
|
+
// behind the e2e cascade: a timed-out harness used to free the
|
|
895
|
+
// channel while a detached worker still held its slot pointer,
|
|
896
|
+
// and the worker segfaulted the NEXT test inside
|
|
897
|
+
// `slot.child_mutex.lock()`. The abandonment itself was a
|
|
898
|
+
// thread-timing window; the joined-and-idle invariant asserted
|
|
899
|
+
// here is its deterministic contract.
|
|
900
|
+
for (&fx.slots) |*slot| {
|
|
901
|
+
try std.testing.expect(slot.worker_thread == null);
|
|
902
|
+
try std.testing.expect(slot.state.load(.acquire) != .running);
|
|
903
|
+
}
|
|
904
|
+
// Joined, not abandoned: the group-kill converged this worker well
|
|
905
|
+
// inside the spawn deadline, so the abandon safety net stayed quiet.
|
|
906
|
+
try std.testing.expectEqual(@as(u32, 0), fx.abandoned_spawn_workers);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// The escaped-descendant shape the spawn teardown deadline exists for:
|
|
910
|
+
// `set -m` enables job control in the child shell, which puts the
|
|
911
|
+
// background job in its OWN process group — outside the group
|
|
912
|
+
// `killPublishedChild` signals — while the job keeps the inherited
|
|
913
|
+
// stdout write end open. The shell exits at once; the escapee never
|
|
914
|
+
// sees the kill; EOF never arrives; the worker's blocking read would
|
|
915
|
+
// hold teardown forever. (This is `setsid` daemonization in portable
|
|
916
|
+
// clothes — macOS ships no setsid(1), but /bin/bash is everywhere the
|
|
917
|
+
// POSIX suites run.) Echoing `$!` hands the test the escapee's pid.
|
|
918
|
+
const escaped_holder_argv: []const []const u8 = &.{ "/bin/bash", "-c", "set -m; sleep 300 & echo $!" };
|
|
919
|
+
|
|
920
|
+
fn parseEscapedPid(h: *Harness) !std.posix.pid_t {
|
|
921
|
+
return std.fmt.parseInt(std.posix.pid_t, h.app_state.model.lineAt(0), 10);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
test "teardown interrupts a spawn worker held hostage by an escaped descendant and joins it with no leak" {
|
|
925
|
+
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
|
926
|
+
var h = try Harness.create();
|
|
927
|
+
defer h.destroy();
|
|
928
|
+
const fx = &h.app_state.effects;
|
|
929
|
+
// Interruption stays on (the default): the group-kill provably
|
|
930
|
+
// misses the escapee, so the best-effort cancel at the halfway
|
|
931
|
+
// mark must interrupt the blocked pipe read and JOIN the worker —
|
|
932
|
+
// the abandon safety net must never fire here.
|
|
933
|
+
fx.spawn_join_deadline_ms = 2_000;
|
|
934
|
+
|
|
935
|
+
test_argv = escaped_holder_argv;
|
|
936
|
+
test_stdin = null;
|
|
937
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
938
|
+
// The echoed pid line proves the worker is mid-stream: child
|
|
939
|
+
// spawned and published, stdout pipe open, read blocked.
|
|
940
|
+
try waitForRealCompletion(&h, sawLine);
|
|
941
|
+
const escaped_pid = try parseEscapedPid(&h);
|
|
942
|
+
// The escapee outlives the interruption by design (nothing kills
|
|
943
|
+
// it); reap it so a 300s sleeper never leaks into the suite.
|
|
944
|
+
defer std.posix.kill(escaped_pid, .KILL) catch {};
|
|
945
|
+
|
|
946
|
+
fx.deinit();
|
|
947
|
+
|
|
948
|
+
// Joined, not leaked: the syscall interruption converged the worker
|
|
949
|
+
// inside the deadline (deinit is deadline-bounded either way, so
|
|
950
|
+
// reaching these asserts already proves it returned).
|
|
951
|
+
try std.testing.expectEqual(@as(u32, 0), fx.abandoned_spawn_workers);
|
|
952
|
+
for (&fx.slots) |*slot| {
|
|
953
|
+
try std.testing.expect(slot.worker_thread == null);
|
|
954
|
+
try std.testing.expect(slot.state.load(.acquire) != .running);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
test "teardown abandons a spawn worker held hostage by an escaped descendant and leaks its context loudly" {
|
|
959
|
+
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
|
960
|
+
const io = std.testing.io;
|
|
961
|
+
var h = try Harness.create();
|
|
962
|
+
defer h.destroy();
|
|
963
|
+
const fx = &h.app_state.effects;
|
|
964
|
+
// Tiny injected budget, interruption disabled: this test pins the
|
|
965
|
+
// SAFETY NET (abandon-and-leak). The interruption path that
|
|
966
|
+
// normally converges this shape first has its own test above.
|
|
967
|
+
fx.spawn_join_deadline_ms = 300;
|
|
968
|
+
fx.spawn_join_interrupt = false;
|
|
969
|
+
|
|
970
|
+
test_argv = escaped_holder_argv;
|
|
971
|
+
test_stdin = null;
|
|
972
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
973
|
+
try waitForRealCompletion(&h, sawLine);
|
|
974
|
+
const escaped_pid = try parseEscapedPid(&h);
|
|
975
|
+
|
|
976
|
+
// Grab the worker context before teardown abandons the slot: after
|
|
977
|
+
// the abandon it is exactly the leaked, process-lived memory the
|
|
978
|
+
// test walks to reach the direct child's recorded pid.
|
|
979
|
+
var leaked: @TypeOf(fx.slots[0].spawn_ctx) = null;
|
|
980
|
+
for (&fx.slots) |*slot| {
|
|
981
|
+
if (slot.kind == .spawn and slot.state.load(.acquire) == .running) leaked = slot.spawn_ctx;
|
|
982
|
+
}
|
|
983
|
+
try std.testing.expect(leaked != null);
|
|
984
|
+
|
|
985
|
+
const start_ns = clock_mod.monotonicNanoseconds();
|
|
986
|
+
fx.deinit();
|
|
987
|
+
const elapsed_ms = (clock_mod.monotonicNanoseconds() - start_ns) / std.time.ns_per_ms;
|
|
988
|
+
|
|
989
|
+
// Teardown returned on the injected budget's order of magnitude
|
|
990
|
+
// (generous bound for congested runners) instead of waiting out the
|
|
991
|
+
// escapee's 300s sleep...
|
|
992
|
+
try std.testing.expect(elapsed_ms < 10_000);
|
|
993
|
+
// ...and abandoned exactly the stuck worker, loudly through the
|
|
994
|
+
// counter seam, leaving no joinable thread and no running slot —
|
|
995
|
+
// the owner may free the channel's memory right now.
|
|
996
|
+
try std.testing.expectEqual(@as(u32, 1), fx.abandoned_spawn_workers);
|
|
997
|
+
for (&fx.slots) |*slot| {
|
|
998
|
+
try std.testing.expect(slot.worker_thread == null);
|
|
999
|
+
try std.testing.expect(slot.state.load(.acquire) != .running);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// The process stays healthy after the leak: a fresh channel runs a
|
|
1003
|
+
// spawn to completion and its own safety net stays quiet.
|
|
1004
|
+
var h2 = try Harness.create();
|
|
1005
|
+
defer h2.destroy();
|
|
1006
|
+
test_argv = &.{ "/bin/sh", "-c", "printf 'alive\\n'" };
|
|
1007
|
+
try h2.app_state.dispatch(&h2.harness.runtime, 1, .start);
|
|
1008
|
+
try waitForRealCompletion(&h2, sawExit);
|
|
1009
|
+
try std.testing.expectEqual(@as(u32, 0), h2.app_state.effects.abandoned_spawn_workers);
|
|
1010
|
+
|
|
1011
|
+
// Wake the abandoned worker under the leak invariant: killing the
|
|
1012
|
+
// escaped holder closes the last stdout write end, the blocked read
|
|
1013
|
+
// reaches EOF, and the worker walks its leaked context — the child
|
|
1014
|
+
// handshake it locks to mark reaping, the pid recorded there — to
|
|
1015
|
+
// reap the (zombie) direct child, then finds itself abandoned and
|
|
1016
|
+
// exits without touching the torn-down channel. If the leak were
|
|
1017
|
+
// not honored, this walk is where a use-after-free would crash the
|
|
1018
|
+
// test. The direct child's disappearance is the deterministic proof
|
|
1019
|
+
// the worker really woke and completed the walk: only its
|
|
1020
|
+
// `child.wait` reaps that zombie.
|
|
1021
|
+
const direct_pid = leaked.?.child_id.?;
|
|
1022
|
+
try std.posix.kill(escaped_pid, .KILL);
|
|
1023
|
+
var waited_ms: usize = 0;
|
|
1024
|
+
while (waited_ms < 20_000) : (waited_ms += 10) {
|
|
1025
|
+
if (std.posix.kill(direct_pid, @enumFromInt(0))) |_| {
|
|
1026
|
+
try std.Io.sleep(io, std.Io.Duration.fromMilliseconds(10), .awake);
|
|
1027
|
+
} else |err| {
|
|
1028
|
+
try std.testing.expectEqual(error.ProcessNotFound, err);
|
|
1029
|
+
break;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
try std.testing.expectError(error.ProcessNotFound, std.posix.kill(direct_pid, @enumFromInt(0)));
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
test "an abandoned spawn worker survives the owner's allocator dying: its leak is process-lived only" {
|
|
1036
|
+
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
|
1037
|
+
const io = std.testing.io;
|
|
1038
|
+
|
|
1039
|
+
// The channel — and every caller-side allocation it makes — lives
|
|
1040
|
+
// in an arena backed by the leak-checking testing allocator and is
|
|
1041
|
+
// deinitialized right after teardown: the exact owner-lifetime
|
|
1042
|
+
// posture the abandon leak must survive (mirroring the file
|
|
1043
|
+
// worker's arena test). The channel struct itself sits in the arena
|
|
1044
|
+
// too, so even the worker's `self` pointer dies with the owner.
|
|
1045
|
+
const Channel = effects_mod.Effects(StreamMsg);
|
|
1046
|
+
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
|
|
1047
|
+
var arena_live = true;
|
|
1048
|
+
defer if (arena_live) arena.deinit();
|
|
1049
|
+
const fx = try arena.allocator().create(Channel);
|
|
1050
|
+
fx.* = Channel.init(arena.allocator());
|
|
1051
|
+
fx.spawn_join_deadline_ms = 300;
|
|
1052
|
+
fx.spawn_join_interrupt = false;
|
|
1053
|
+
|
|
1054
|
+
// A short-lived escapee this time: it exits on its own (~2s), so
|
|
1055
|
+
// the abandoned worker's wake needs no outside kill — by then the
|
|
1056
|
+
// leaked context is the only handle on the effect left anywhere.
|
|
1057
|
+
fx.spawn(.{
|
|
1058
|
+
.key = 1,
|
|
1059
|
+
.argv = &.{ "/bin/bash", "-c", "set -m; sleep 2 & echo held" },
|
|
1060
|
+
.on_line = null,
|
|
1061
|
+
.on_exit = null,
|
|
1062
|
+
});
|
|
1063
|
+
// The queued "held" line proves the worker published its child and
|
|
1064
|
+
// reached the blocking read (publish happens-before the enqueue).
|
|
1065
|
+
var setup_ms: usize = 0;
|
|
1066
|
+
while (setup_ms < 20_000) : (setup_ms += 10) {
|
|
1067
|
+
if (fx.hasPending()) break;
|
|
1068
|
+
try std.Io.sleep(io, std.Io.Duration.fromMilliseconds(10), .awake);
|
|
1069
|
+
}
|
|
1070
|
+
try std.testing.expect(fx.hasPending());
|
|
1071
|
+
var leaked: @TypeOf(fx.slots[0].spawn_ctx) = null;
|
|
1072
|
+
for (&fx.slots) |*slot| {
|
|
1073
|
+
if (slot.kind == .spawn and slot.state.load(.acquire) == .running) leaked = slot.spawn_ctx;
|
|
1074
|
+
}
|
|
1075
|
+
try std.testing.expect(leaked != null);
|
|
1076
|
+
|
|
1077
|
+
fx.deinit();
|
|
1078
|
+
try std.testing.expectEqual(@as(u32, 1), fx.abandoned_spawn_workers);
|
|
1079
|
+
const direct_pid = leaked.?.child_id.?;
|
|
1080
|
+
|
|
1081
|
+
// Kill the owner's allocator: everything the channel ever got from
|
|
1082
|
+
// it — including the channel struct — is gone. The abandoned worker
|
|
1083
|
+
// must not notice: all it can still reach (its context, that
|
|
1084
|
+
// context's buffers, the executor io) is `process_allocator`
|
|
1085
|
+
// storage.
|
|
1086
|
+
arena.deinit();
|
|
1087
|
+
arena_live = false;
|
|
1088
|
+
|
|
1089
|
+
// The escapee exits on its own; EOF wakes the abandoned worker,
|
|
1090
|
+
// which walks only its leaked context (marking reaping under the
|
|
1091
|
+
// context's child mutex, reaping the zombie direct child) and exits
|
|
1092
|
+
// without touching the dead arena — if any of its reachable memory
|
|
1093
|
+
// were caller-allocated, this walk is where the use-after-free
|
|
1094
|
+
// would crash the test. The zombie's disappearance proves the wake.
|
|
1095
|
+
var waited_ms: usize = 0;
|
|
1096
|
+
while (waited_ms < 20_000) : (waited_ms += 10) {
|
|
1097
|
+
if (std.posix.kill(direct_pid, @enumFromInt(0))) |_| {
|
|
1098
|
+
try std.Io.sleep(io, std.Io.Duration.fromMilliseconds(10), .awake);
|
|
1099
|
+
} else |err| {
|
|
1100
|
+
try std.testing.expectEqual(error.ProcessNotFound, err);
|
|
1101
|
+
break;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
try std.testing.expectError(error.ProcessNotFound, std.posix.kill(direct_pid, @enumFromInt(0)));
|
|
1105
|
+
|
|
1106
|
+
// And the happy path still frees everything through the same seams:
|
|
1107
|
+
// a fresh channel backed DIRECTLY by the testing allocator runs a
|
|
1108
|
+
// real spawn to completion and tears down joined — the leak check
|
|
1109
|
+
// at test end guards the caller-side allocations, and
|
|
1110
|
+
// `joinWorker`/`deinit` return the context and executor io to
|
|
1111
|
+
// `process_allocator`.
|
|
1112
|
+
var healthy = Channel.init(std.testing.allocator);
|
|
1113
|
+
defer healthy.deinit();
|
|
1114
|
+
healthy.spawn(.{
|
|
1115
|
+
.key = 2,
|
|
1116
|
+
.argv = &.{ "/bin/sh", "-c", "printf 'alive\\n'" },
|
|
1117
|
+
.on_line = null,
|
|
1118
|
+
.on_exit = null,
|
|
1119
|
+
});
|
|
1120
|
+
var healthy_ms: usize = 0;
|
|
1121
|
+
while (healthy_ms < 20_000) : (healthy_ms += 10) {
|
|
1122
|
+
if (healthy.hasPending()) break;
|
|
1123
|
+
try std.Io.sleep(io, std.Io.Duration.fromMilliseconds(10), .awake);
|
|
1124
|
+
}
|
|
1125
|
+
try std.testing.expect(healthy.hasPending());
|
|
1126
|
+
healthy.deinit();
|
|
1127
|
+
try std.testing.expectEqual(@as(u32, 0), healthy.abandoned_spawn_workers);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
test "a spawn teardown storm never leaks a worker into the next harness" {
|
|
1131
|
+
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
|
1132
|
+
// The e2e cascade's shape, run deterministically and repeatedly: a
|
|
1133
|
+
// harness dies while its real child still streams (or while a
|
|
1134
|
+
// cancel is racing the spawn), then the next round builds a fresh
|
|
1135
|
+
// executor over recycled heap. Before the join fix an abandoned
|
|
1136
|
+
// worker could resume inside freed memory and crash a later round;
|
|
1137
|
+
// with it, destroy cannot return while any worker lives. Bounded
|
|
1138
|
+
// iterations keep the storm CI-cheap.
|
|
1139
|
+
var round: usize = 0;
|
|
1140
|
+
while (round < 8) : (round += 1) {
|
|
1141
|
+
var h = try Harness.create();
|
|
1142
|
+
// Runs at each iteration's end — the storm's teardown — and on
|
|
1143
|
+
// an error return alike.
|
|
1144
|
+
defer h.destroy();
|
|
1145
|
+
test_argv = &.{ "/bin/sh", "-c", "echo tick; sleep 30" };
|
|
1146
|
+
test_stdin = null;
|
|
1147
|
+
try h.app_state.dispatch(&h.harness.runtime, 1, .start);
|
|
1148
|
+
// Odd rounds race a wire cancel against the spawn before the
|
|
1149
|
+
// teardown; even rounds tear down against the bare stream.
|
|
1150
|
+
if (round % 2 == 1) try h.app_state.dispatch(&h.harness.runtime, 1, .stop);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
867
1154
|
test "real executor children inherit the parent environment" {
|
|
868
1155
|
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
|
869
1156
|
var h = try Harness.create();
|
package/src/runtime/root.zig
CHANGED
|
@@ -98,6 +98,24 @@ pub const EffectAudioEventKind = runtime_effects.EffectAudioEventKind;
|
|
|
98
98
|
pub const EffectAudioSource = runtime_effects.EffectAudioSource;
|
|
99
99
|
pub const audioCachePath = runtime_effects.audioCachePath;
|
|
100
100
|
pub const max_effect_audio_path_bytes = runtime_effects.max_effect_audio_path_bytes;
|
|
101
|
+
pub const EffectHostResult = runtime_effects.EffectHostResult;
|
|
102
|
+
pub const HostCallBinding = runtime_effects.HostCallBinding;
|
|
103
|
+
pub const max_effect_host_name_bytes = runtime_effects.max_effect_host_name_bytes;
|
|
104
|
+
pub const max_effect_host_payload_bytes = runtime_effects.max_effect_host_payload_bytes;
|
|
105
|
+
pub const max_effect_host_result_bytes = runtime_effects.max_effect_host_result_bytes;
|
|
106
|
+
|
|
107
|
+
const runtime_ts_core_host = @import("ts_core_host.zig");
|
|
108
|
+
pub const TsCoreHost = runtime_ts_core_host.TsCoreHost;
|
|
109
|
+
pub const ts_core_request_key_base = runtime_ts_core_host.request_key_base;
|
|
110
|
+
pub const ts_core_timer_key_base = runtime_ts_core_host.timer_key_base;
|
|
111
|
+
pub const ts_core_effect_key_base = runtime_ts_core_host.effect_key_base;
|
|
112
|
+
pub const ts_core_delay_key_base = runtime_ts_core_host.delay_key_base;
|
|
113
|
+
pub const ts_core_clip_write_key_base = runtime_ts_core_host.clip_write_key_base;
|
|
114
|
+
pub const ts_core_spawn_key_base = runtime_ts_core_host.spawn_key_base;
|
|
115
|
+
pub const ts_core_audio_key_base = runtime_ts_core_host.audio_key_base;
|
|
116
|
+
|
|
117
|
+
const runtime_ts_ui_app = @import("ts_ui_app.zig");
|
|
118
|
+
pub const TsUiApp = runtime_ts_ui_app.TsUiApp;
|
|
101
119
|
|
|
102
120
|
const runtime_session_journal = @import("session_journal.zig");
|
|
103
121
|
const runtime_session_record = @import("session_record.zig");
|
|
@@ -226,7 +226,13 @@ fn effectRegeneratesUnderReplay(record: journal.EffectResultRecord) bool {
|
|
|
226
226
|
// position ticks, completions, platform failures — is an
|
|
227
227
|
// external input and must be fed.
|
|
228
228
|
.audio => record.audio_kind == .rejected,
|
|
229
|
-
|
|
229
|
+
// Host-request rejections mark themselves with the exit reason
|
|
230
|
+
// (the `.host` record encoding); host answers must be fed.
|
|
231
|
+
.host => record.exit_reason == .rejected,
|
|
232
|
+
// Launch-env deliveries are exactly what must NOT regenerate:
|
|
233
|
+
// the recorded values feed the replayed envMsgs dispatch so the
|
|
234
|
+
// replay launch's environment is never consulted.
|
|
235
|
+
.line, .clock, .env => false,
|
|
230
236
|
};
|
|
231
237
|
}
|
|
232
238
|
|
package/src/runtime/tests.zig
CHANGED
|
@@ -20,6 +20,8 @@ test {
|
|
|
20
20
|
_ = @import("effects_file_tests.zig");
|
|
21
21
|
_ = @import("effects_clipboard_tests.zig");
|
|
22
22
|
_ = @import("effects_audio_tests.zig");
|
|
23
|
+
_ = @import("effects_host_tests.zig");
|
|
24
|
+
_ = @import("ts_core_host_tests.zig");
|
|
23
25
|
_ = @import("clock.zig");
|
|
24
26
|
_ = @import("frame_profile.zig");
|
|
25
27
|
_ = @import("markdown_app_tests.zig");
|