@native-sdk/cli 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/build/app.zig +273 -65
  2. package/build/ts_run.mjs +6 -8
  3. package/build.zig +341 -361
  4. package/native-sdk.d.ts +6 -3
  5. package/package.json +13 -11
  6. package/packages/core/compile-surface/core.ts +559 -0
  7. package/packages/core/package-lock.json +375 -12
  8. package/packages/core/package.json +9 -6
  9. package/packages/core/scripts/compiler_typecheck.mjs +58 -0
  10. package/packages/core/scripts/gen_case_tables.mjs +130 -0
  11. package/packages/core/scripts/gen_declarations.mjs +97 -0
  12. package/packages/core/scripts/run_external_core_compiler.mjs +108 -0
  13. package/packages/core/scripts/stage_external_core.mjs +148 -0
  14. package/packages/core/sdk/core.d.ts +363 -0
  15. package/packages/core/sdk/events.d.ts +65 -0
  16. package/packages/core/sdk/text.d.ts +51 -0
  17. package/packages/core/src/checker.ts +3 -3
  18. package/packages/core/src/cli.ts +40 -38
  19. package/packages/core/src/contract.ts +749 -0
  20. package/packages/core/src/devhost.ts +4 -3
  21. package/packages/core/src/diagnostics.ts +5 -7
  22. package/packages/core/src/{transpile.ts → frontend.ts} +38 -50
  23. package/packages/core/src/infer.ts +1 -1
  24. package/packages/core/src/typed_ast.ts +16 -15
  25. package/packages/core/src/wyhash.ts +79 -0
  26. package/skill-data/native-ui/SKILL.md +4 -2
  27. package/skill-data/ts-core/SKILL.md +29 -29
  28. package/src/platform/macos/appkit_host.m +51 -3
  29. package/src/platform/types.zig +4 -0
  30. package/src/platform/windows/gpu_surface_renderer.cpp +2280 -0
  31. package/src/platform/windows/gpu_surface_renderer.h +86 -0
  32. package/src/platform/windows/root.zig +298 -20
  33. package/src/platform/windows/webview2_host.cpp +343 -33
  34. package/src/primitives/canvas/code.zig +50 -0
  35. package/src/primitives/canvas/code_tests.zig +174 -1
  36. package/src/primitives/canvas/frame.zig +45 -1
  37. package/src/primitives/canvas/gpu.zig +6 -0
  38. package/src/primitives/canvas/render_tests.zig +93 -0
  39. package/src/primitives/canvas/root.zig +2 -0
  40. package/src/primitives/canvas/serialization.zig +150 -21
  41. package/src/primitives/canvas/themes/geist.zig +51 -5
  42. package/src/primitives/canvas/tokens.zig +33 -4
  43. package/src/primitives/canvas/ui.zig +52 -7
  44. package/src/primitives/canvas/ui_markup.zig +38 -1
  45. package/src/primitives/canvas/ui_markup_compiled.zig +28 -0
  46. package/src/primitives/canvas/ui_markup_contract.zig +9 -0
  47. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  48. package/src/primitives/canvas/ui_markup_view_tests.zig +10 -2
  49. package/src/primitives/canvas/ui_schema.zig +5 -0
  50. package/src/primitives/canvas/ui_schema_tests.zig +4 -3
  51. package/src/primitives/canvas/ui_tests.zig +14 -0
  52. package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
  53. package/src/primitives/canvas/widget_invalidation.zig +11 -1
  54. package/src/primitives/canvas/widget_layout.zig +260 -21
  55. package/src/primitives/canvas/widget_metrics.zig +45 -9
  56. package/src/primitives/canvas/widget_render.zig +220 -70
  57. package/src/primitives/canvas/widget_render_controls.zig +79 -21
  58. package/src/primitives/canvas/widget_render_style.zig +52 -8
  59. package/src/primitives/canvas/widget_text_input.zig +2 -0
  60. package/src/primitives/canvas/widgets.zig +53 -2
  61. package/src/runtime/canvas_frame.zig +60 -7
  62. package/src/runtime/canvas_frame_invalidation_tests.zig +80 -0
  63. package/src/runtime/canvas_frame_packet_tests.zig +83 -9
  64. package/src/runtime/canvas_frame_patch_tests.zig +16 -0
  65. package/src/runtime/canvas_images.zig +8 -2
  66. package/src/runtime/canvas_widget_clipboard_tests.zig +1 -1
  67. package/src/runtime/canvas_widget_runtime.zig +11 -8
  68. package/src/runtime/effects.zig +6 -0
  69. package/src/runtime/effects_tests.zig +30 -0
  70. package/src/runtime/gpu_surface_events.zig +38 -7
  71. package/src/runtime/media_surface_tests.zig +1 -1
  72. package/src/runtime/runtime_event_tests.zig +74 -0
  73. package/src/runtime/ts_core_host.zig +38 -38
  74. package/src/runtime/ts_ui_app.zig +12 -12
  75. package/src/runtime/ui_app.zig +10 -8
  76. package/src/runtime/ui_app_tests.zig +67 -0
  77. package/src/runtime/view.zig +6 -0
  78. package/src/runtime/view_canvas.zig +15 -0
  79. package/src/runtime/view_widget_text.zig +6 -4
  80. package/src/runtime/window_view_runtime.zig +1 -0
  81. package/src/tooling/manifest.zig +32 -0
  82. package/src/tooling/raw_manifest.zig +4 -0
  83. package/src/tooling/templates.zig +34 -26
  84. package/src/tooling/ts_core.zig +55 -34
  85. package/src/tooling/verbs.zig +1 -1
  86. package/tools/corewire/core_abi.zig +169 -0
  87. package/tools/corewire/emit.zig +2418 -0
  88. package/tools/corewire/emit_facade.zig +3984 -0
  89. package/tools/corewire/emit_profile.zig +501 -0
  90. package/tools/corewire/main.zig +561 -0
  91. package/tools/corewire/shim_rt.zig +632 -0
  92. package/tools/corewire/sidecar.zig +2507 -0
  93. package/packages/core/rt/rt.zig +0 -1986
  94. package/packages/core/src/emitter.ts +0 -11898
package/build.zig CHANGED
@@ -199,28 +199,26 @@ pub fn build(b: *std.Build) void {
199
199
  // corewire, the contract-sidecar shim generator (tools/corewire):
200
200
  // std-only unit suites, one test root per source file (tests live
201
201
  // in the file they cover, and imported files' tests do not run
202
- // under an importer's root). The conformance suite — both lanes per
203
- // ts-core fixture, compared by layout fingerprint and
204
- // model-contract artifact — rides the ts-core e2e block, since it
205
- // needs node and the transpiler toolchain.
202
+ // under an importer's root). The conformance suite — every fixture's
203
+ // generated mirror validated over its frontend-emitted contract —
204
+ // rides the ts-core e2e block, since it needs node and the frontend
205
+ // toolchain.
206
206
  const corewire_sidecar_tests = testArtifact(b, module(b, target, optimize, "tools/corewire/sidecar.zig"));
207
207
  const corewire_emit_tests = testArtifact(b, module(b, target, optimize, "tools/corewire/emit.zig"));
208
208
  const corewire_facade_tests = testArtifact(b, module(b, target, optimize, "tools/corewire/emit_facade.zig"));
209
209
  const corewire_profile_tests = testArtifact(b, module(b, target, optimize, "tools/corewire/emit_profile.zig"));
210
- const corewire_extract_tests = testArtifact(b, module(b, target, optimize, "tools/corewire/extract.zig"));
211
210
  const corewire_shim_rt_tests = testArtifact(b, module(b, target, optimize, "tools/corewire/shim_rt.zig"));
212
- // The paired-core root generator (tests/compiled-core): its emitted
213
- // surface rules are pinned here so the env-gated batteries cannot
214
- // drift silently between supplied-archive runs.
215
- const gen_paired_tests = testArtifact(b, module(b, target, optimize, "tests/compiled-core/gen_paired.zig"));
216
-
217
- // Transpiled-core end-to-end suite: tests/ts-core/fixture.ts is
218
- // emitted by the repo's own transpiler AT BUILD TIME (never a
219
- // committed Zig snapshot) and driven through the real runtime via
220
- // `TsCoreHost`. Gated on node plus the transpiler package's
221
- // installed dependency: absent either, the suite is skipped (the
222
- // bridge itself stays covered by src/runtime/ts_core_host_tests.zig
223
- // against a hand-written emitted-ABI core).
211
+
212
+ // TypeScript-core end-to-end suite: each fixture core is compiled
213
+ // through the external core compiler AT BUILD TIME (never a
214
+ // committed archive) and its e2e battery drives the linked archive
215
+ // through the real runtime via `TsCoreHost` over the generated
216
+ // mirror. Gated on node plus the package's installed dependencies
217
+ // (`npm ci` in packages/core — the compiler and the frontend
218
+ // toolchain arrive together): absent either, the suite is skipped
219
+ // (the bridge itself stays covered by
220
+ // src/runtime/ts_core_host_tests.zig against a hand-written
221
+ // core-ABI module).
224
222
  const ts_core_e2e_tests = tsCoreE2eArtifact(b, target, optimize, desktop_mod, tooling_mod);
225
223
 
226
224
  const ui_markup_mod = module(b, target, optimize, "src/primitives/canvas/ui_markup.zig");
@@ -481,12 +479,11 @@ pub fn build(b: *std.Build) void {
481
479
  test_step.dependOn(&b.addRunArtifact(corewire_emit_tests).step);
482
480
  test_step.dependOn(&b.addRunArtifact(corewire_facade_tests).step);
483
481
  test_step.dependOn(&b.addRunArtifact(corewire_profile_tests).step);
484
- test_step.dependOn(&b.addRunArtifact(corewire_extract_tests).step);
485
482
  test_step.dependOn(&b.addRunArtifact(corewire_shim_rt_tests).step);
486
- test_step.dependOn(&b.addRunArtifact(gen_paired_tests).step);
487
483
  if (ts_core_e2e_tests) |ts_core_artifacts| {
488
- const ts_core_e2e_step = b.step("test-ts-core-e2e", "Run the transpiled-core end-to-end suites (requires node)");
484
+ const ts_core_e2e_step = b.step("test-ts-core-e2e", "Run the TypeScript-core end-to-end suites over externally compiled fixture cores (requires node and `npm ci` in packages/core)");
489
485
  const host_e2e_run = b.addRunArtifact(ts_core_artifacts.host);
486
+ const markup_e2e_run = b.addRunArtifact(ts_core_artifacts.markup);
490
487
  const soundboard_e2e_run = b.addRunArtifact(ts_core_artifacts.soundboard);
491
488
  const monitor_e2e_run = b.addRunArtifact(ts_core_artifacts.system_monitor);
492
489
  const scaffold_ide_e2e_run = b.addRunArtifact(ts_core_artifacts.scaffold_ide);
@@ -495,31 +492,19 @@ pub fn build(b: *std.Build) void {
495
492
  scaffold_ide_e2e_run.has_side_effects = true;
496
493
  const ai_chat_e2e_run = b.addRunArtifact(ts_core_artifacts.ai_chat);
497
494
  const sidecar_conformance_run = b.addRunArtifact(ts_core_artifacts.sidecar_conformance);
498
- const sidecar_conformance_step = b.step("sidecar-conformance", "Prove corewire-generated mirrors fingerprint-identical to transpiler output (requires node)");
495
+ const sidecar_conformance_step = b.step("sidecar-conformance", "Validate corewire-generated mirrors over every fixture's frontend-emitted contract (requires node)");
499
496
  sidecar_conformance_step.dependOn(&sidecar_conformance_run.step);
500
- // Skipped unless the caller supplies a compiled-core archive:
501
- // the repo builds none, so the step gates on the env var and
502
- // `zig build test` stays green without it.
503
- const parity_step = b.step("test-external-core-parity", "Run the compiled-core behavior-parity suite (requires node and NATIVE_SDK_EXTERNAL_CORE_ARCHIVE=<link input[" ++ [_]u8{std.fs.path.delimiter} ++ "link input...]>; skipped when unset)");
504
- if (ts_core_artifacts.external_core_parity) |parity_tests| {
505
- const parity_run = b.addRunArtifact(parity_tests);
506
- parity_step.dependOn(&parity_run.step);
507
- test_step.dependOn(&parity_run.step);
508
- }
509
- // The full-corpus twin: each fixture app's e2e battery over a
510
- // paired core, gated per fixture on its archive/sidecar env
511
- // pair; with none supplied the step is a clean no-op and
512
- // `zig build test` is untouched.
513
- const compiled_parity_step = b.step("test-compiled-core-parity", "Run each fixture app's e2e battery over a paired core — transpiled lane vs a caller-supplied compiled-core archive (requires node and NATIVE_SDK_EXTERNAL_CORE_ARCHIVE_<FIXTURE> + NATIVE_SDK_EXTERNAL_CORE_SIDECAR_<FIXTURE>; fixtures without both are skipped)");
514
- for (ts_core_artifacts.compiled_core_parity) |battery| {
515
- const battery_run = b.addRunArtifact(battery.tests);
516
- compiled_parity_step.dependOn(&battery_run.step);
517
- test_step.dependOn(&battery_run.step);
518
- }
497
+ // ABI-law suite over a real compiled core: the markup fixture's
498
+ // archive driven directly through the C ABI (collect invariant,
499
+ // deterministic re-init, channel envelopes, integer classes).
500
+ const abi_laws_run = b.addRunArtifact(ts_core_artifacts.external_core_abi_laws);
501
+ const abi_laws_step = b.step("test-external-core-abi", "Run the compiled-core ABI-law suite over the markup fixture's archive (requires node and `npm ci` in packages/core)");
502
+ abi_laws_step.dependOn(&abi_laws_run.step);
503
+ test_step.dependOn(&abi_laws_run.step);
519
504
  // The corpus contract artifacts an external core toolchain
520
- // consumes: per fixture, the extracted contract sidecar, the
521
- // generated entry module, and the compiler profile that builds
522
- // it, under zig-out/core-contracts.
505
+ // consumes: per fixture, the frontend-emitted contract sidecar
506
+ // (after projection), the generated entry module, and the
507
+ // compiler profile that builds it, under zig-out/core-contracts.
523
508
  const contracts_step = b.step("stage-core-contracts", "Install each ts-core fixture's contract sidecar, generated entry module, and compiler profile under zig-out/core-contracts (requires node)");
524
509
  for (ts_core_artifacts.core_contracts) |contract| {
525
510
  const dir: std.Build.InstallDir = .{ .custom = b.fmt("core-contracts/{s}", .{contract.name}) };
@@ -528,11 +513,13 @@ pub fn build(b: *std.Build) void {
528
513
  contracts_step.dependOn(&b.addInstallFileWithDir(contract.profile, dir, "core_profile.json").step);
529
514
  }
530
515
  ts_core_e2e_step.dependOn(&host_e2e_run.step);
516
+ ts_core_e2e_step.dependOn(&markup_e2e_run.step);
531
517
  ts_core_e2e_step.dependOn(&soundboard_e2e_run.step);
532
518
  ts_core_e2e_step.dependOn(&monitor_e2e_run.step);
533
519
  ts_core_e2e_step.dependOn(&scaffold_ide_e2e_run.step);
534
520
  ts_core_e2e_step.dependOn(&ai_chat_e2e_run.step);
535
521
  test_step.dependOn(&host_e2e_run.step);
522
+ test_step.dependOn(&markup_e2e_run.step);
536
523
  test_step.dependOn(&soundboard_e2e_run.step);
537
524
  test_step.dependOn(&monitor_e2e_run.step);
538
525
  test_step.dependOn(&scaffold_ide_e2e_run.step);
@@ -566,8 +553,11 @@ pub fn build(b: *std.Build) void {
566
553
  .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "\"gpu_surfaces\"" },
567
554
  .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "\"gpuSurfaces\"" },
568
555
  .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "gpuFirstFrameLatencyNs: number" },
556
+ .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "gpuBackend: NativeSdkGpuSurfaceBackend;" },
557
+ .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "export type NativeSdkGpuSurfaceBackendRequest = \"metal\" | \"software\";" },
558
+ .{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "gpuBackend?: NativeSdkGpuSurfaceBackendRequest;" },
569
559
  });
570
- addFileContainsCheckStep(b, file_contains_checker, test_step, "test-ts-toolchain-twins", "Verify the CLI's toolchain-resolution gate and its direct-`zig build` twin stay in lockstep (both resolve the aliased real compiler @typescript/old from packages/core — the same origin runtime imports it from — hold its resolved version against the manifest-read pin, never probe the unused @typescript/typescript6 wrapper, and teach instead of panicking)", &.{
560
+ addFileContainsCheckStep(b, file_contains_checker, test_step, "test-ts-toolchain-twins", "Verify the CLI's toolchain-resolution gate and its direct-`zig build` twin stay in lockstep (both resolve the aliased real compiler @typescript/old from packages/core — the same origin runtime imports it from — hold its resolved version against the manifest-read pin, never probe a stray compat wrapper, and teach instead of panicking)", &.{
571
561
  // The resolution twins probe the aliased REAL compiler
572
562
  // (@typescript/old — the package typed_ast.ts and ts_run.mjs
573
563
  // actually load) — manifest AND entrypoint, in lockstep. The
@@ -582,9 +572,9 @@ pub fn build(b: *std.Build) void {
582
572
  // only what runtime loads, from runtime's own walk origin, and
583
573
  // leave the declared-but-unimported wrapper out of the verdict.
584
574
  .{ .path = "src/tooling/ts_core.zig", .pattern = "Validation tracks ONLY what runtime loads" },
585
- .{ .path = "src/tooling/ts_core.zig", .pattern = "wrapper is deliberately NOT probed" },
575
+ .{ .path = "src/tooling/ts_core.zig", .pattern = "deliberately NOT probed" },
586
576
  .{ .path = "build/app.zig", .pattern = "Validation tracks ONLY what runtime loads" },
587
- .{ .path = "build/app.zig", .pattern = "wrapper is deliberately NOT probed" },
577
+ .{ .path = "build/app.zig", .pattern = "deliberately NOT probed" },
588
578
  // The reciprocal cross-references that keep the twins findable
589
579
  // from each other.
590
580
  .{ .path = "src/tooling/ts_core.zig", .pattern = "build/app.zig's tsToolchainResolution" },
@@ -630,19 +620,19 @@ pub fn build(b: *std.Build) void {
630
620
  .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "close:function(options){return invoke('native-sdk.view.close',viewSelectorPayload(options))" },
631
621
  });
632
622
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-command-contracts", "Verify command docs match native view update contracts", &.{
633
- .{ .path = "docs/src/app/commands/page.mdx", .pattern = ".text = \"Refreshed\"" },
634
- .{ .path = "docs/src/app/commands/page.mdx", .pattern = "const commands = await window.zero.commands.list();" },
623
+ .{ .path = "docs/src/app/docs/commands/page.mdx", .pattern = ".text = \"Refreshed\"" },
624
+ .{ .path = "docs/src/app/docs/commands/page.mdx", .pattern = "const commands = await window.zero.commands.list();" },
635
625
  });
636
626
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-native-view-contracts", "Verify native surface docs describe view identity", &.{
637
- .{ .path = "docs/src/app/native-surfaces/page.mdx", .pattern = "ViewInfo.id" },
638
- .{ .path = "docs/src/app/native-surfaces/page.mdx", .pattern = "window.zero.views.update(\"status\"" },
639
- .{ .path = "docs/src/app/native-surfaces/page.mdx", .pattern = "first-frame latency budget" },
627
+ .{ .path = "docs/src/app/docs/native-surfaces/page.mdx", .pattern = "ViewInfo.id" },
628
+ .{ .path = "docs/src/app/docs/native-surfaces/page.mdx", .pattern = "window.zero.views.update(\"status\"" },
629
+ .{ .path = "docs/src/app/docs/native-surfaces/page.mdx", .pattern = "first-frame latency budget" },
640
630
  });
641
631
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-shell-manifest-contracts", "Verify app.zon docs describe shell compatibility window labels", &.{
642
- .{ .path = "docs/src/app/app-zon/page.mdx", .pattern = "labels must stay unique across both lists" },
632
+ .{ .path = "docs/src/app/docs/app-zon/page.mdx", .pattern = "labels must stay unique across both lists" },
643
633
  });
644
634
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-media-producer-contracts", "Verify the media producer docs' typed callback stays mirrored by the compile-shaped pin in media_surface_tests.zig", &.{
645
- .{ .path = "docs/src/app/media-producers/page.mdx", .pattern = "producer: media.MediaSurfaceProducer" },
635
+ .{ .path = "docs/src/app/docs/media-producers/page.mdx", .pattern = "producer: media.MediaSurfaceProducer" },
646
636
  .{ .path = "src/runtime/media_surface_tests.zig", .pattern = "producer: media.MediaSurfaceProducer" },
647
637
  });
648
638
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-session-replay-image-codec", "Verify the replay runner installs the host image codec headlessly (the desktop arms cannot link in unit tests; the null-fallback arm is covered in session_tests.zig)", &.{
@@ -986,9 +976,37 @@ pub fn build(b: *std.Build) void {
986
976
  // this step until the encoder comment, the host decoder comment, and
987
977
  // the patterns below move with it.
988
978
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-wire-format-version-prose", "Verify wire-format version prose matches the packet version constant", &.{
989
- .{ .path = "src/primitives/canvas/serialization.zig", .pattern = "pub const binary_packet_version: u8 = 4;" },
990
- .{ .path = "src/primitives/canvas/serialization.zig", .pattern = "Compact binary gpu-surface packet encoding (wire format v4)." },
991
- .{ .path = "src/platform/macos/appkit_host.m", .pattern = "Compact binary gpu-surface packet decoding (wire format v4)." },
979
+ .{ .path = "src/primitives/canvas/serialization.zig", .pattern = "pub const binary_packet_version: u8 = 5;" },
980
+ .{ .path = "src/primitives/canvas/serialization.zig", .pattern = "Compact binary gpu-surface packet encoding (wire format v5)." },
981
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "Compact binary gpu-surface packet decoding (wire format v5)." },
982
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "Compact binary gpu-surface packet decoding (wire format v5)." },
983
+ });
984
+ addFileContainsCheckStep(b, file_contains_checker, test_step, "test-windows-gpu-packet-presenter", "Verify Windows uses retained Direct2D packets with recovery, bounded resources, and dirty-region pixel fallback", &.{
985
+ .{ .path = "src/platform/windows/root.zig", .pattern = ".present_gpu_surface_packet_binary_fn = presentGpuSurfacePacketBinary" },
986
+ .{ .path = "src/platform/windows/root.zig", .pattern = ".backend = if (event.gpu_backend == 1) .direct2d else .software" },
987
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "view.gpu_surface->present(request, &info)" },
988
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "InvalidateRect(view.hwnd, &info.dirty_rects[index], FALSE)" },
989
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "for (size_t y_index = y0; y_index < y1; ++y_index)" },
990
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "InvalidateRect(view.hwnd, partial_update ? &dirty_pixels : nullptr, FALSE)" },
991
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "D2D1_RENDER_TARGET_TYPE_HARDWARE" },
992
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "retained_commands_ = std::move(next_retained)" },
993
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "PushAxisAlignedClip(d2dRect(requested)" },
994
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "const float expansion = effect.spread + blur" },
995
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "releaseImageBitmap(action.id)" },
996
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "resumeAndDrawBlur" },
997
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "const Rect target = blurTarget(*command, outer_clip)" },
998
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "blur_snapshot_->CopyFromBitmap" },
999
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "command.effect.blur * transformScale(command.transform)" },
1000
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "D2D1_EXTEND_MODE_CLAMP" },
1001
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "!GetClientRect(view.hwnd, &client) || !PtInRect(&client, sample)" },
1002
+ .{ .path = "src/platform/windows/gpu_surface_renderer.cpp", .pattern = "draw_line(text.text, text.origin.x, text.origin.y)" },
1003
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "gpuSurfaceUpdateRegionRects" },
1004
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "info.dirty_rect_count > 0" },
1005
+ .{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "view->gpu_force_full_repaint_pending = true" },
1006
+ .{ .path = "src/platform/windows/root.zig", .pattern = ".canvas_frame_full_repaint = event.force_full_repaint != 0" },
1007
+ .{ .path = ".github/scripts/windows-canvas-smoke.sh", .pattern = "gpu_backend=direct2d" },
1008
+ .{ .path = ".github/scripts/windows-effects-smoke.sh", .pattern = "gpu_backend=direct2d" },
1009
+ .{ .path = "build/app.zig", .pattern = "app_mod.linkSystemLibrary(\"d2d1\", .{})" },
992
1010
  });
993
1011
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-gpu-packet-blur-effects", "Verify AppKit GPU packet presenter applies blur effects", &.{
994
1012
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "NativeSdkPacketApplyBlur" },
@@ -1224,8 +1242,8 @@ pub fn build(b: *std.Build) void {
1224
1242
  .{ .path = "src/platform/macos/root.zig", .pattern = ".appearance_changed => state.emit" },
1225
1243
  });
1226
1244
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-builtin-bridge-policy", "Verify bridge policy docs include guarded dialog commands", &.{
1227
- .{ .path = "docs/src/app/security/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1228
- .{ .path = "docs/src/app/bridge/builtin-commands/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1245
+ .{ .path = "docs/src/app/docs/security/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1246
+ .{ .path = "docs/src/app/docs/bridge/builtin-commands/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1229
1247
  });
1230
1248
 
1231
1249
  addTestStep(b, "test-geometry", "Run geometry module tests", geometry_tests);
@@ -1250,6 +1268,12 @@ pub fn build(b: *std.Build) void {
1250
1268
  // on a Windows runner makes that a Windows-native receipt. The same
1251
1269
  // tests also run inside `zig build test` via the canvas-frame shard.
1252
1270
  addTestStep(b, "test-canvas-fonts", "Run the runtime font-registry tests (includes the registered-CJK Chinese receipt)", filteredTestArtifact(b, desktop_mod, "canvas-fonts-tests", &.{"runtime.canvas_font_tests.test"}));
1271
+ // The console-attachment regression is Windows-only, so the general
1272
+ // Linux `zig build test` lane can only compile and skip it. Expose the
1273
+ // exact test as a focused step for the real-Windows CI runner; this
1274
+ // keeps CREATE_NO_WINDOW behavior covered without making that runner
1275
+ // execute the entire framework runtime suite.
1276
+ addTestStep(b, "test-windows-effects-no-console", "Verify Windows effect spawns run without an attached console", filteredTestArtifact(b, desktop_mod, "windows-effects-no-console-tests", &.{"runtime.effects_tests.test.Windows background spawns run without an attached console"}));
1253
1277
  addTestStep(b, "test-automation-protocol", "Run automation protocol tests", automation_protocol_tests);
1254
1278
  addTestStep(b, "test-automation-cli", "Run native automate CLI tests", automation_cli_tests);
1255
1279
  addTestStep(b, "test-markup-cli", "Run native markup CLI tests", markup_cli_tests);
@@ -2951,6 +2975,10 @@ fn testArtifact(b: *std.Build, mod: *std.Build.Module) *std.Build.Step.Compile {
2951
2975
  /// installed dependency (`npm ci` in packages/core) is missing.
2952
2976
  const TsCoreE2eArtifacts = struct {
2953
2977
  host: *std.Build.Step.Compile,
2978
+ /// The markup battery is its own binary: the compiled-core symbol
2979
+ /// set is a fixed-prefix C ABI, so one process carries ONE archive
2980
+ /// — every fixture battery links exactly its own core.
2981
+ markup: *std.Build.Step.Compile,
2954
2982
  soundboard: *std.Build.Step.Compile,
2955
2983
  system_monitor: *std.Build.Step.Compile,
2956
2984
  /// The stock-IDE contract: a fresh scaffold (and the committed TS
@@ -2958,37 +2986,22 @@ const TsCoreE2eArtifacts = struct {
2958
2986
  /// paths, and builds keep working with node_modules deleted.
2959
2987
  scaffold_ide: *std.Build.Step.Compile,
2960
2988
  ai_chat: *std.Build.Step.Compile,
2961
- /// Sidecar-shim conformance (tests/sidecar): every fixture built
2962
- /// through BOTH lanes — the transpiler and corewire's generated
2963
- /// mirror — and compared by layout fingerprint and model-contract
2964
- /// artifact.
2989
+ /// Sidecar-shim conformance (tests/sidecar): every fixture's
2990
+ /// generated mirror validated over its frontend-emitted contract
2991
+ /// (plus the hand-written ground-truth sidecars), and every shim
2992
+ /// fully analyzed and linked against the stub core.
2965
2993
  sidecar_conformance: *std.Build.Step.Compile,
2966
- /// Behavior parity against a REAL compiled core: built only when
2967
- /// NATIVE_SDK_EXTERNAL_CORE_ARCHIVE names the archive(s) to link
2968
- /// (path-delimiter-separated link inputs exporting the markup
2969
- /// fixture's attested symbol set); null — the suite is skipped —
2970
- /// otherwise.
2971
- external_core_parity: ?*std.Build.Step.Compile,
2972
- /// The full-corpus compiled-core batteries: each entry is one
2973
- /// fixture app's OWN e2e suite compiled over a paired core — the
2974
- /// transpiled lane plus a generated mirror dispatching into a
2975
- /// caller-supplied compiled-core archive, byte-compared at every
2976
- /// seam. Built per fixture only when its archive/sidecar env pair
2977
- /// (NATIVE_SDK_EXTERNAL_CORE_ARCHIVE_<FIXTURE> and
2978
- /// NATIVE_SDK_EXTERNAL_CORE_SIDECAR_<FIXTURE>) is supplied; empty
2979
- /// — every battery skipped — otherwise.
2980
- compiled_core_parity: []const CompiledCoreParity,
2994
+ /// The ABI-law suite over a REAL compiled core: the markup
2995
+ /// fixture's archive driven directly through the C ABI bindings
2996
+ /// (boot fence, collect invariant, deterministic re-init, channel
2997
+ /// envelopes, integer classes).
2998
+ external_core_abi_laws: *std.Build.Step.Compile,
2981
2999
  /// Per-fixture contract artifacts for an external core toolchain:
2982
3000
  /// the effective contract sidecar and its TypeScript facade/profile
2983
3001
  /// projections, installed by the stage-core-contracts step.
2984
3002
  core_contracts: []const CoreContract,
2985
3003
  };
2986
3004
 
2987
- const CompiledCoreParity = struct {
2988
- name: []const u8,
2989
- tests: *std.Build.Step.Compile,
2990
- };
2991
-
2992
3005
  const CoreContract = struct {
2993
3006
  name: []const u8,
2994
3007
  sidecar: std.Build.LazyPath,
@@ -2996,34 +3009,6 @@ const CoreContract = struct {
2996
3009
  profile: std.Build.LazyPath,
2997
3010
  };
2998
3011
 
2999
- /// One fixture's compiled-core supply: the archive link input(s) and
3000
- /// the archive's own emitted contract sidecar. Both come as a pair —
3001
- /// a real archive's build_id can only match its co-emitted sidecar, so
3002
- /// one without the other is a misconfiguration, refused with a
3003
- /// teaching rather than skipped into silence.
3004
- const CompiledCoreSupply = struct {
3005
- archives: []const u8,
3006
- sidecar: std.Build.LazyPath,
3007
- };
3008
-
3009
- fn compiledCoreEnv(b: *std.Build, comptime suffix: []const u8) ?CompiledCoreSupply {
3010
- const archive_var = "NATIVE_SDK_EXTERNAL_CORE_ARCHIVE_" ++ suffix;
3011
- const sidecar_var = "NATIVE_SDK_EXTERNAL_CORE_SIDECAR_" ++ suffix;
3012
- const archives = b.graph.environ_map.get(archive_var);
3013
- const sidecar = b.graph.environ_map.get(sidecar_var);
3014
- if (archives == null and sidecar == null) return null;
3015
- if (archives == null or sidecar == null) {
3016
- std.debug.panic(
3017
- "{s} and {s} come as a pair: a compiled-core fixture needs both its archive link input(s) and the archive's own emitted contract sidecar",
3018
- .{ archive_var, sidecar_var },
3019
- );
3020
- }
3021
- return .{
3022
- .archives = b.dupe(archives.?),
3023
- .sidecar = .{ .cwd_relative = b.dupe(sidecar.?) },
3024
- };
3025
- }
3026
-
3027
3012
  fn tsCoreE2eArtifact(
3028
3013
  b: *std.Build,
3029
3014
  target: std.Build.ResolvedTarget,
@@ -3032,28 +3017,85 @@ fn tsCoreE2eArtifact(
3032
3017
  tooling_mod: *std.Build.Module,
3033
3018
  ) ?TsCoreE2eArtifacts {
3034
3019
  const node = b.findProgram(&.{"node"}, &.{}) catch return null;
3020
+ // Both toolchains arrive with one `npm ci` in packages/core: the
3021
+ // frontend's TypeScript compiler and the external core compiler
3022
+ // (unless NATIVE_SDK_CORE_COMPILER points at the pinned release's
3023
+ // command directly).
3035
3024
  b.build_root.handle.access(
3036
3025
  b.graph.io,
3037
- "packages/core/node_modules/@typescript/typescript6",
3026
+ "packages/core/node_modules/@typescript/old",
3038
3027
  .{},
3039
3028
  ) catch return null;
3029
+ if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER") == null) {
3030
+ b.build_root.handle.access(
3031
+ b.graph.io,
3032
+ "packages/core/node_modules/scriptc/dist/main.js",
3033
+ .{},
3034
+ ) catch return null;
3035
+ }
3036
+
3037
+ // corewire (the contract-sidecar mirror/facade/profile generator),
3038
+ // compiled for the build host: the fixture compiles and the
3039
+ // conformance shims all run it.
3040
+ const corewire_mod = b.createModule(.{
3041
+ .root_source_file = b.path("tools/corewire/main.zig"),
3042
+ .target = target,
3043
+ .optimize = optimize,
3044
+ });
3045
+ const corewire_exe = b.addExecutable(.{
3046
+ .name = "corewire",
3047
+ .root_module = corewire_mod,
3048
+ .use_llvm = @import("build/app.zig").useLlvmWorkaround(target),
3049
+ });
3040
3050
 
3041
- // Each fixture stages its own copy of rt.zig, so each emitted core
3042
- // owns a distinct rt kernel instance — the process contract the
3043
- // coexistence e2e test pins (two live cores, no shared arenas).
3044
- const fixture_mod = tsCoreFixtureModule(b, target, optimize, node, "tests/ts-core/fixture.ts");
3045
- const markup_fixture_mod = tsCoreFixtureModule(b, target, optimize, node, "tests/ts-core/markup_fixture.ts");
3051
+ // Each fixture core compiles through the external core compiler at
3052
+ // build time; the battery drives the linked archive through the
3053
+ // generated mirror. The compiled-core symbol set is a fixed-prefix
3054
+ // C ABI, so one process carries ONE archive — each battery below is
3055
+ // its own binary linking exactly its own core. The tests/ts-core
3056
+ // fixtures are single-file cores, staged into their own
3057
+ // compile-source directories.
3058
+ const host_src = b.addWriteFiles();
3059
+ _ = host_src.addCopyFile(b.path("tests/ts-core/fixture.ts"), "fixture.ts");
3060
+ const host_fixture = externalCoreFixtureModule(b, target, optimize, node, corewire_exe, .{
3061
+ .entry = "tests/ts-core/fixture.ts",
3062
+ .src_dir = host_src.getDirectory(),
3063
+ .name = "host_fixture_core",
3064
+ // The fixture drives pastBytes to the f64-exact boundary (2^53):
3065
+ // no honest i64 declaration exists there, so the compiled
3066
+ // projection carries the slot as f64.
3067
+ .f64_slots = &.{"Model.pastBytes"},
3068
+ });
3069
+ const fixture_mod = host_fixture.module;
3070
+ const markup_src = b.addWriteFiles();
3071
+ _ = markup_src.addCopyFile(b.path("tests/ts-core/markup_fixture.ts"), "markup_fixture.ts");
3072
+ const markup_fixture = externalCoreFixtureModule(b, target, optimize, node, corewire_exe, .{
3073
+ .entry = "tests/ts-core/markup_fixture.ts",
3074
+ .src_dir = markup_src.getDirectory(),
3075
+ .name = "markup_core",
3076
+ });
3077
+ const markup_fixture_mod = markup_fixture.module;
3046
3078
 
3047
3079
  const e2e_mod = module(b, target, optimize, "tests/ts-core/host_e2e_tests.zig");
3048
3080
  e2e_mod.addImport("native_sdk", desktop_mod);
3049
3081
  e2e_mod.addImport("ts_core_fixture", fixture_mod);
3050
- e2e_mod.addImport("ts_markup_fixture", markup_fixture_mod);
3082
+
3083
+ // The markup battery: the .native view + automation + record/replay
3084
+ // guarantees over the markup fixture's compiled core.
3085
+ const markup_e2e_mod = module(b, target, optimize, "tests/ts-core/markup_e2e_tests.zig");
3086
+ markup_e2e_mod.addImport("native_sdk", desktop_mod);
3087
+ markup_e2e_mod.addImport("ts_markup_fixture", markup_fixture_mod);
3051
3088
 
3052
3089
  // The soundboard-ts example's core and markup, tested as one app:
3053
3090
  // the test root stages beside a copy of the example's app.native so
3054
3091
  // the compiled markup engine builds the SHIPPING view over the
3055
- // emitted model.
3056
- const soundboard_core_mod = tsCoreFixtureModule(b, target, optimize, node, "examples/soundboard-ts/src/core.ts");
3092
+ // core's model.
3093
+ const soundboard_fixture = externalCoreFixtureModule(b, target, optimize, node, corewire_exe, .{
3094
+ .entry = "examples/soundboard-ts/src/core.ts",
3095
+ .src_dir = b.path("examples/soundboard-ts/src"),
3096
+ .name = "soundboard_core",
3097
+ });
3098
+ const soundboard_core_mod = soundboard_fixture.module;
3057
3099
  const soundboard_stage = b.addWriteFiles();
3058
3100
  const soundboard_root = soundboard_stage.addCopyFile(b.path("tests/ts-core/soundboard_e2e_tests.zig"), "soundboard_e2e_tests.zig");
3059
3101
  _ = soundboard_stage.addCopyFile(b.path("examples/soundboard-ts/src/app.native"), "app.native");
@@ -3068,7 +3110,12 @@ fn tsCoreE2eArtifact(
3068
3110
  // The system-monitor-ts example's core and markup, tested the same
3069
3111
  // way — plus the ORIGINAL Zig example's committed sampler captures,
3070
3112
  // staged as fixtures so both ports parse the same recorded truth.
3071
- const monitor_core_mod = tsCoreFixtureModule(b, target, optimize, node, "examples/system-monitor-ts/src/core.ts");
3113
+ const monitor_fixture = externalCoreFixtureModule(b, target, optimize, node, corewire_exe, .{
3114
+ .entry = "examples/system-monitor-ts/src/core.ts",
3115
+ .src_dir = b.path("examples/system-monitor-ts/src"),
3116
+ .name = "system_monitor_core",
3117
+ });
3118
+ const monitor_core_mod = monitor_fixture.module;
3072
3119
  const monitor_stage = b.addWriteFiles();
3073
3120
  const monitor_root = monitor_stage.addCopyFile(b.path("tests/ts-core/system_monitor_e2e_tests.zig"), "system_monitor_e2e_tests.zig");
3074
3121
  _ = monitor_stage.addCopyFile(b.path("examples/system-monitor-ts/src/app.native"), "app.native");
@@ -3092,7 +3139,12 @@ fn tsCoreE2eArtifact(
3092
3139
  // The ai-chat-ts example's core and markup, tested the same way:
3093
3140
  // the chat client for an OpenAI-compatible endpoint, driven through
3094
3141
  // the fake fetch feed (no network) with its shipping markup.
3095
- const ai_chat_core_mod = tsCoreFixtureModule(b, target, optimize, node, "examples/ai-chat-ts/src/core.ts");
3142
+ const ai_chat_fixture = externalCoreFixtureModule(b, target, optimize, node, corewire_exe, .{
3143
+ .entry = "examples/ai-chat-ts/src/core.ts",
3144
+ .src_dir = b.path("examples/ai-chat-ts/src"),
3145
+ .name = "ai_chat_core",
3146
+ });
3147
+ const ai_chat_core_mod = ai_chat_fixture.module;
3096
3148
  const ai_chat_stage = b.addWriteFiles();
3097
3149
  const ai_chat_root = ai_chat_stage.addCopyFile(b.path("tests/ts-core/ai_chat_e2e_tests.zig"), "ai_chat_e2e_tests.zig");
3098
3150
  _ = ai_chat_stage.addCopyFile(b.path("examples/ai-chat-ts/src/app.native"), "app.native");
@@ -3104,58 +3156,42 @@ fn tsCoreE2eArtifact(
3104
3156
  ai_chat_mod.addImport("native_sdk", desktop_mod);
3105
3157
  ai_chat_mod.addImport("ts_ai_chat_core", ai_chat_core_mod);
3106
3158
 
3107
- // Sidecar-shim conformance: pair every fixture's transpiled module
3108
- // with a corewire-generated mirror. The markup fixture's sidecar is
3109
- // the committed hand-written one (independent ground truth for the
3110
- // schema); the rest are extracted from the transpiled modules at
3111
- // build time, so corpus fixtures cannot go stale against their
3112
- // sidecars.
3113
- const corewire_mod = b.createModule(.{
3114
- .root_source_file = b.path("tools/corewire/main.zig"),
3115
- .target = target,
3116
- .optimize = optimize,
3117
- });
3118
- const corewire_exe = b.addExecutable(.{
3119
- .name = "corewire",
3120
- .root_module = corewire_mod,
3121
- .use_llvm = @import("build/app.zig").useLlvmWorkaround(target),
3122
- });
3123
- const extract_mod = module(b, target, optimize, "tools/corewire/extract.zig");
3124
-
3159
+ // Sidecar-shim conformance: a corewire-generated mirror per corpus
3160
+ // fixture. The markup fixture's sidecar is the committed
3161
+ // hand-written one (independent ground truth for the schema); the
3162
+ // rest are the frontend-emitted contracts from the fixture compiles
3163
+ // above, so corpus mirrors cannot go stale against their cores.
3125
3164
  const conformance_mod = module(b, target, optimize, "tests/sidecar/conformance_tests.zig");
3126
3165
  conformance_mod.addImport("native_sdk", desktop_mod);
3127
3166
  // The canonical value encoder the envelope and snapshot axes compare
3128
3167
  // against (the same module the generated shims stage).
3129
3168
  conformance_mod.addImport("corewire_rt", module(b, target, optimize, "tools/corewire/shim_rt.zig"));
3130
- conformance_mod.addImport("ts_markup_core", markup_fixture_mod);
3131
3169
  conformance_mod.addImport("shim_markup_core", sidecarShimModule(b, target, optimize, corewire_exe, b.path("tests/sidecar/markup_fixture.contract.json")));
3132
3170
  // The integer-class fixture: a hand-written sidecar attesting mixed
3133
3171
  // i64/u64 slot classes, so the suite drives boundary and full-range
3134
3172
  // integer values through a generated mirror's decode paths.
3135
3173
  conformance_mod.addImport("shim_integer_core", sidecarShimModule(b, target, optimize, corewire_exe, b.path("tests/sidecar/integer_fixture.contract.json")));
3136
3174
  const conformance_fixtures = [_]struct {
3137
- ts_import: []const u8,
3138
3175
  shim_import: []const u8,
3139
3176
  contract_name: []const u8,
3140
- core_mod: *std.Build.Module,
3141
- entry: []const u8,
3177
+ core: ExternalCoreFixture,
3142
3178
  /// Attested integer slots the compiled projection carries as f64
3143
3179
  /// (values that reach the f64-exact boundary have no honest i64
3144
3180
  /// declaration on that side).
3145
3181
  f64_slots: []const []const u8 = &.{},
3146
3182
  }{
3147
- .{ .ts_import = "ts_host_core", .shim_import = "shim_host_core", .contract_name = "host-fixture", .core_mod = fixture_mod, .entry = "tests/ts-core/fixture.ts", .f64_slots = &.{"Model.pastBytes"} },
3148
- .{ .ts_import = "ts_soundboard_core", .shim_import = "shim_soundboard_core", .contract_name = "soundboard", .core_mod = soundboard_core_mod, .entry = "examples/soundboard-ts/src/core.ts" },
3149
- .{ .ts_import = "ts_monitor_core", .shim_import = "shim_monitor_core", .contract_name = "system-monitor", .core_mod = monitor_core_mod, .entry = "examples/system-monitor-ts/src/core.ts" },
3150
- .{ .ts_import = "ts_ai_chat_core", .shim_import = "shim_ai_chat_core", .contract_name = "ai-chat", .core_mod = ai_chat_core_mod, .entry = "examples/ai-chat-ts/src/core.ts" },
3183
+ .{ .shim_import = "shim_host_core", .contract_name = "host-fixture", .core = host_fixture, .f64_slots = &.{"Model.pastBytes"} },
3184
+ .{ .shim_import = "shim_soundboard_core", .contract_name = "soundboard", .core = soundboard_fixture },
3185
+ .{ .shim_import = "shim_monitor_core", .contract_name = "system-monitor", .core = monitor_fixture },
3186
+ .{ .shim_import = "shim_ai_chat_core", .contract_name = "ai-chat", .core = ai_chat_fixture },
3151
3187
  };
3152
3188
  // The corpus contract artifacts an external core toolchain consumes
3153
3189
  // (stage-core-contracts): the effective sidecar plus its generated
3154
- // entry module and compiler profile, per fixture.
3190
+ // entry module and compiler profile, per fixture. Every corewire
3191
+ // consumer reads the FRONTEND-emitted contract.
3155
3192
  var core_contracts: std.ArrayList(CoreContract) = .empty;
3156
3193
  {
3157
- const markup_sidecar = sidecarExtractJson(b, target, optimize, extract_mod, markup_fixture_mod, "tests/ts-core/markup_fixture.ts");
3158
- const projections = facadeProjections(b, corewire_exe, markup_sidecar, &.{});
3194
+ const projections = facadeProjections(b, corewire_exe, markup_fixture.contract, &.{});
3159
3195
  core_contracts.append(b.allocator, .{
3160
3196
  .name = "markup-fixture",
3161
3197
  .sidecar = projections.sidecar,
@@ -3164,10 +3200,8 @@ fn tsCoreE2eArtifact(
3164
3200
  }) catch @panic("OOM");
3165
3201
  }
3166
3202
  for (conformance_fixtures) |fixture| {
3167
- const sidecar_json = sidecarExtractJson(b, target, optimize, extract_mod, fixture.core_mod, fixture.entry);
3168
- conformance_mod.addImport(fixture.ts_import, fixture.core_mod);
3169
- conformance_mod.addImport(fixture.shim_import, sidecarShimModule(b, target, optimize, corewire_exe, sidecar_json));
3170
- const projections = facadeProjections(b, corewire_exe, sidecar_json, fixture.f64_slots);
3203
+ conformance_mod.addImport(fixture.shim_import, sidecarShimModule(b, target, optimize, corewire_exe, fixture.core.contract));
3204
+ const projections = facadeProjections(b, corewire_exe, fixture.core.contract, fixture.f64_slots);
3171
3205
  core_contracts.append(b.allocator, .{
3172
3206
  .name = fixture.contract_name,
3173
3207
  .sidecar = projections.sidecar,
@@ -3176,161 +3210,34 @@ fn tsCoreE2eArtifact(
3176
3210
  }) catch @panic("OOM");
3177
3211
  }
3178
3212
 
3179
- // Compiled-core behavior parity (tests/sidecar/
3180
- // external_core_parity_tests.zig): the executable half of the
3181
- // conformance story, gated on a caller-supplied compiled-core
3182
- // archive because the repo builds none itself. The env var carries
3183
- // one or more link inputs (path-delimiter-separated) that together
3184
- // export the markup fixture's attested symbol set; the binary pairs
3185
- // a FRESH generated mirror with them (the conformance binary's
3186
- // mirror links the stub core's exports — one process cannot carry
3187
- // both symbol sets). A real archive's sidecar carries the compile's
3188
- // own build_id, which the mirror's boot fence checks against the
3189
- // identity getters — so the caller supplies the archive's OWN
3190
- // emitted sidecar through NATIVE_SDK_EXTERNAL_CORE_SIDECAR (the
3191
- // committed fixture sidecar stays the default for stub-shaped
3192
- // callers that restate its identity).
3193
- const external_core_parity: ?*std.Build.Step.Compile = if (b.graph.environ_map.get("NATIVE_SDK_EXTERNAL_CORE_ARCHIVE")) |archives| blk: {
3194
- const parity_mod = module(b, target, optimize, "tests/sidecar/external_core_parity_tests.zig");
3195
- parity_mod.link_libc = true;
3196
- parity_mod.addImport("corewire_rt", module(b, target, optimize, "tools/corewire/shim_rt.zig"));
3197
- parity_mod.addImport("core_abi", module(b, target, optimize, "tools/corewire/core_abi.zig"));
3198
- parity_mod.addImport("ts_core", markup_fixture_mod);
3199
- const parity_sidecar: std.Build.LazyPath = if (b.graph.environ_map.get("NATIVE_SDK_EXTERNAL_CORE_SIDECAR")) |sidecar|
3200
- .{ .cwd_relative = b.dupe(sidecar) }
3201
- else
3202
- b.path("tests/sidecar/markup_fixture.contract.json");
3203
- parity_mod.addImport("shim_core", sidecarShimModule(b, target, optimize, corewire_exe, parity_sidecar));
3204
- var inputs = std.mem.tokenizeScalar(u8, archives, std.fs.path.delimiter);
3205
- while (inputs.next()) |input| {
3206
- parity_mod.addObjectFile(.{ .cwd_relative = b.dupe(input) });
3207
- }
3208
- // The generated mirror is the only projection this lane uses;
3209
- // sidecarShimModule validates exactly that surface. Do not run
3210
- // the all-projections checker here: an external compiler's
3211
- // sidecar may legitimately predate facade-only metadata while
3212
- // remaining a valid mirror contract for its linked archive.
3213
- break :blk filteredTestArtifact(b, parity_mod, "external-core-parity-tests", &.{});
3214
- } else null;
3215
-
3216
- // The full-corpus compiled-core batteries: each supplied fixture's
3217
- // OWN e2e test root recompiled over a paired core (the transpiled
3218
- // lane plus a fresh generated mirror linked against the caller's
3219
- // archive), so every behavioral assertion the fixture app carries
3220
- // runs through the compiled core with byte parity checked at every
3221
- // seam (commands, snapshots, subscriptions, channels, helpers).
3222
- // Env-gated per fixture like the markup parity suite: unset means
3223
- // the battery is never built and `zig build test` stays green.
3224
- var compiled_core_parity: std.ArrayList(CompiledCoreParity) = .empty;
3225
- const compiled_core_fixtures = [_]struct {
3226
- name: []const u8,
3227
- supply: ?CompiledCoreSupply,
3228
- ts_mod: *std.Build.Module,
3229
- root: std.Build.LazyPath,
3230
- core_import: []const u8,
3231
- /// The host suite's second lane (the markup fixture) rides the
3232
- /// same binary, transpiler-only: one archive per process is the
3233
- /// compiled-core contract.
3234
- second_import: ?[]const u8 = null,
3235
- second_mod: ?*std.Build.Module = null,
3236
- }{
3237
- .{ .name = "host", .supply = compiledCoreEnv(b, "HOST"), .ts_mod = fixture_mod, .root = b.path("tests/ts-core/host_e2e_tests.zig"), .core_import = "ts_core_fixture", .second_import = "ts_markup_fixture", .second_mod = markup_fixture_mod },
3238
- // The markup battery is the mirror image of the host one: the
3239
- // markup fixture's core pairs, and the host fixture rides along
3240
- // transpiler-only as the second lane.
3241
- .{ .name = "markup", .supply = compiledCoreEnv(b, "MARKUP"), .ts_mod = markup_fixture_mod, .root = b.path("tests/ts-core/markup_e2e_tests.zig"), .core_import = "ts_markup_fixture", .second_import = "ts_core_fixture", .second_mod = fixture_mod },
3242
- .{ .name = "soundboard", .supply = compiledCoreEnv(b, "SOUNDBOARD"), .ts_mod = soundboard_core_mod, .root = soundboard_root, .core_import = "ts_soundboard_core" },
3243
- .{ .name = "system-monitor", .supply = compiledCoreEnv(b, "SYSTEM_MONITOR"), .ts_mod = monitor_core_mod, .root = monitor_root, .core_import = "ts_system_monitor_core" },
3244
- .{ .name = "ai-chat", .supply = compiledCoreEnv(b, "AI_CHAT"), .ts_mod = ai_chat_core_mod, .root = ai_chat_root, .core_import = "ts_ai_chat_core" },
3245
- };
3246
- for (compiled_core_fixtures) |entry| {
3247
- const supply = entry.supply orelse continue;
3248
- const paired_mod = pairedCoreModule(b, target, optimize, corewire_exe, entry.ts_mod, supply);
3249
- const battery_mod = b.createModule(.{
3250
- .root_source_file = entry.root,
3251
- .target = target,
3252
- .optimize = optimize,
3253
- });
3254
- battery_mod.addImport("native_sdk", desktop_mod);
3255
- battery_mod.addImport(entry.core_import, paired_mod);
3256
- if (entry.second_import) |second| battery_mod.addImport(second, entry.second_mod.?);
3257
- const battery = filteredTestArtifact(b, battery_mod, b.fmt("compiled-core-{s}-tests", .{entry.name}), &.{});
3258
- compiled_core_parity.append(b.allocator, .{ .name = b.dupe(entry.name), .tests = battery }) catch @panic("OOM");
3259
- }
3213
+ // The ABI-law suite (tests/sidecar/external_core_abi_tests.zig):
3214
+ // the executable half of the conformance story — the markup
3215
+ // fixture's REAL archive driven directly through the C ABI
3216
+ // bindings, beside a FRESH generated mirror (the conformance
3217
+ // binary's mirror links the stub core's exports — one process
3218
+ // cannot carry both symbol sets). The mirror generates from the
3219
+ // archive's OWN co-emitted sidecar, so its boot fence checks the
3220
+ // compile's real build_id against the identity getters.
3221
+ const abi_laws_mod = module(b, target, optimize, "tests/sidecar/external_core_abi_tests.zig");
3222
+ abi_laws_mod.link_libc = true;
3223
+ abi_laws_mod.addImport("corewire_rt", module(b, target, optimize, "tools/corewire/shim_rt.zig"));
3224
+ abi_laws_mod.addImport("core_abi", module(b, target, optimize, "tools/corewire/core_abi.zig"));
3225
+ abi_laws_mod.addImport("shim_core", sidecarShimModule(b, target, optimize, corewire_exe, markup_fixture.sidecar));
3226
+ abi_laws_mod.addObjectFile(markup_fixture.archive);
3260
3227
 
3261
3228
  return .{
3262
3229
  .host = filteredTestArtifact(b, e2e_mod, "ts-core-e2e-tests", &.{}),
3230
+ .markup = filteredTestArtifact(b, markup_e2e_mod, "ts-markup-e2e-tests", &.{}),
3263
3231
  .soundboard = filteredTestArtifact(b, soundboard_mod, "ts-soundboard-e2e-tests", &.{}),
3264
3232
  .system_monitor = filteredTestArtifact(b, monitor_mod, "ts-system-monitor-e2e-tests", &.{}),
3265
3233
  .scaffold_ide = filteredTestArtifact(b, scaffold_ide_mod, "ts-scaffold-ide-e2e-tests", &.{}),
3266
3234
  .ai_chat = filteredTestArtifact(b, ai_chat_mod, "ts-ai-chat-e2e-tests", &.{}),
3267
3235
  .sidecar_conformance = filteredTestArtifact(b, conformance_mod, "sidecar-conformance-tests", &.{}),
3268
- .external_core_parity = external_core_parity,
3269
- .compiled_core_parity = compiled_core_parity.toOwnedSlice(b.allocator) catch @panic("OOM"),
3236
+ .external_core_abi_laws = filteredTestArtifact(b, abi_laws_mod, "external-core-abi-tests", &.{}),
3270
3237
  .core_contracts = core_contracts.toOwnedSlice(b.allocator) catch @panic("OOM"),
3271
3238
  };
3272
3239
  }
3273
3240
 
3274
- /// One fixture's paired-core module (tests/compiled-core): generate
3275
- /// the lockstep root from the transpiled module's own export surface,
3276
- /// stage it beside the pairing library and the mirror-value converter,
3277
- /// bind the transpiled lane and a mirror generated from the supplied
3278
- /// contract sidecar, and link the caller's compiled-core archive(s).
3279
- fn pairedCoreModule(
3280
- b: *std.Build,
3281
- target: std.Build.ResolvedTarget,
3282
- optimize: std.builtin.OptimizeMode,
3283
- corewire_exe: *std.Build.Step.Compile,
3284
- ts_mod: *std.Build.Module,
3285
- supply: CompiledCoreSupply,
3286
- ) *std.Build.Module {
3287
- const gen_root = b.addWriteFiles().add("gen_paired_main.zig",
3288
- \\//! Generated by the build: emit a fixture's paired-core root
3289
- \\//! from its transpiled module (tests/compiled-core/gen_paired.zig).
3290
- \\const std = @import("std");
3291
- \\const gen = @import("gen_paired");
3292
- \\const core = @import("ts_core");
3293
- \\pub fn main(init: std.process.Init) !void {
3294
- \\ try gen.emitMain(core, init);
3295
- \\}
3296
- \\
3297
- );
3298
- const gen_mod = b.createModule(.{
3299
- .root_source_file = gen_root,
3300
- .target = target,
3301
- .optimize = optimize,
3302
- });
3303
- gen_mod.addImport("gen_paired", module(b, target, optimize, "tests/compiled-core/gen_paired.zig"));
3304
- gen_mod.addImport("ts_core", ts_mod);
3305
- const gen_exe = b.addExecutable(.{
3306
- .name = "gen-paired",
3307
- .root_module = gen_mod,
3308
- .use_llvm = @import("build/app.zig").useLlvmWorkaround(target),
3309
- });
3310
- const gen_run = b.addRunArtifact(gen_exe);
3311
- const paired_src = gen_run.addOutputFileArg("paired.zig");
3312
-
3313
- const staged = b.addWriteFiles();
3314
- const paired_root = staged.addCopyFile(paired_src, "paired.zig");
3315
- _ = staged.addCopyFile(b.path("tests/compiled-core/paired_core.zig"), "paired_core.zig");
3316
- _ = staged.addCopyFile(b.path("tests/sidecar/mirror_value.zig"), "mirror_value.zig");
3317
- const mod = b.createModule(.{
3318
- .root_source_file = paired_root,
3319
- .target = target,
3320
- .optimize = optimize,
3321
- });
3322
- mod.link_libc = true;
3323
- mod.addImport("ts_lane", ts_mod);
3324
- mod.addImport("shim_lane", sidecarShimModule(b, target, optimize, corewire_exe, supply.sidecar));
3325
- mod.addImport("corewire_rt", module(b, target, optimize, "tools/corewire/shim_rt.zig"));
3326
- mod.addImport("core_abi", module(b, target, optimize, "tools/corewire/core_abi.zig"));
3327
- var inputs = std.mem.tokenizeScalar(u8, supply.archives, std.fs.path.delimiter);
3328
- while (inputs.next()) |input| {
3329
- mod.addObjectFile(.{ .cwd_relative = b.dupe(input) });
3330
- }
3331
- return mod;
3332
- }
3333
-
3334
3241
  const FacadeProjections = struct {
3335
3242
  sidecar: std.Build.LazyPath,
3336
3243
  facade: std.Build.LazyPath,
@@ -3390,83 +3297,156 @@ fn sidecarShimModule(
3390
3297
  });
3391
3298
  }
3392
3299
 
3393
- /// Extract a fixture's contract sidecar from its transpiled module
3394
- /// (tools/corewire/extract.zig) — a generated one-line main per
3395
- /// fixture, so corpus sidecars regenerate whenever the fixture or the
3396
- /// transpiler changes.
3397
- fn sidecarExtractJson(
3398
- b: *std.Build,
3399
- target: std.Build.ResolvedTarget,
3400
- optimize: std.builtin.OptimizeMode,
3401
- extract_mod: *std.Build.Module,
3402
- core_mod: *std.Build.Module,
3300
+ /// One externally compiled TS fixture core: the corewire-generated
3301
+ /// mirror over the fixture's compiled archive, staged as one module in
3302
+ /// the app lane's exact shape (core.zig + its shim runtime), with the
3303
+ /// archive linked behind it — plus the frontend-emitted contract
3304
+ /// sidecar (the document corewire's projections consume) and the
3305
+ /// archive's own co-emitted sidecar.
3306
+ const ExternalCoreFixture = struct {
3307
+ module: *std.Build.Module,
3308
+ /// The frontend-emitted contract (stage-core-contracts, the
3309
+ /// conformance shims).
3310
+ contract: std.Build.LazyPath,
3311
+ /// The compiled-core archive (already linked into `module`; the
3312
+ /// ABI-law suite links it directly).
3313
+ archive: std.Build.LazyPath,
3314
+ /// The archive's OWN co-emitted contract sidecar — the document its
3315
+ /// mirror must generate from (the boot identity fence pairs them).
3316
+ sidecar: std.Build.LazyPath,
3317
+ };
3318
+
3319
+ const ExternalCoreFixtureSpec = struct {
3320
+ /// The entry module, build-root-relative (the contract's stated
3321
+ /// entry spelling).
3403
3322
  entry: []const u8,
3404
- ) std.Build.LazyPath {
3405
- const root = b.addWriteFiles().add("extract_main.zig", b.fmt(
3406
- \\//! Generated by the build: extract the contract sidecar from a
3407
- \\//! transpiled fixture core (see tools/corewire/extract.zig).
3408
- \\const std = @import("std");
3409
- \\const extract = @import("extract");
3410
- \\const core = @import("ts_core");
3411
- \\pub fn main(init: std.process.Init) !void {{
3412
- \\ try extract.emitMain(core, "{s}", init);
3413
- \\}}
3414
- \\
3415
- , .{entry}));
3416
- const mod = b.createModule(.{
3417
- .root_source_file = root,
3418
- .target = target,
3419
- .optimize = optimize,
3420
- });
3421
- mod.addImport("extract", extract_mod);
3422
- mod.addImport("ts_core", core_mod);
3423
- const exe = b.addExecutable(.{
3424
- .name = "sidecar-extract",
3425
- .root_module = mod,
3426
- .use_llvm = @import("build/app.zig").useLlvmWorkaround(target),
3427
- });
3428
- const run = b.addRunArtifact(exe);
3429
- return run.addOutputFileArg("core.contract.json");
3430
- }
3323
+ /// The compile-source directory holding the core's whole import
3324
+ /// graph (an example's src/, or a staged single-file fixture dir).
3325
+ src_dir: std.Build.LazyPath,
3326
+ /// The archive's symbol-safe stem (`lib<name>.a`).
3327
+ name: []const u8,
3328
+ /// Attested integer slots the compiled projection carries as f64
3329
+ /// (values that reach the f64-exact boundary have no honest i64
3330
+ /// declaration on that side) — corewire's --f64-slot demotions,
3331
+ /// applied to the compile profile and every downstream projection.
3332
+ f64_slots: []const []const u8 = &.{},
3333
+ };
3431
3334
 
3432
- /// Transpile one TS fixture core at build time and pair the emitted
3433
- /// Zig with its rt kernel in one generated module.
3434
- fn tsCoreFixtureModule(
3335
+ /// Compile one TS fixture core through the external core compiler at
3336
+ /// build time — the same pipeline the app lane runs (build/app.zig
3337
+ /// tsCoreStage): frontend check + contract, corewire facade/profile
3338
+ /// projection, compile-tree staging, the exact-pinned compile, and the
3339
+ /// mirror generated from the co-emitted sidecar.
3340
+ fn externalCoreFixtureModule(
3435
3341
  b: *std.Build,
3436
3342
  target: std.Build.ResolvedTarget,
3437
3343
  optimize: std.builtin.OptimizeMode,
3438
3344
  node: []const u8,
3439
- fixture_path: []const u8,
3440
- ) *std.Build.Module {
3441
- const transpile = b.addSystemCommand(&.{node});
3442
- transpile.addFileArg(b.path("packages/core/src/cli.ts"));
3443
- transpile.addFileArg(b.path(fixture_path));
3444
- transpile.addArg("-o");
3445
- const emitted_core = transpile.addOutputFileArg("core.zig");
3446
- // The transpiler reads its own sources, the SDK modules, and the
3447
- // core's WHOLE import graph at run time; declare them all so edits
3448
- // re-emit the fixture. The graph is declared as every sibling .ts of
3449
- // the entry (a superset of the reachable imports: over-approximation
3450
- // only re-runs the transpile, never misses a stale input).
3451
- tsCoreAddDirInputs(b, transpile, "packages/core/sdk");
3452
- tsCoreAddDirInputs(b, transpile, std.fs.path.dirname(fixture_path) orelse ".");
3453
- const transpiler_sources = [_][]const u8{
3454
- "checker.ts", "cli.ts", "diagnostics.ts", "emitter.ts", "infer.ts", "modules.ts", "transpile.ts", "typed_ast.ts", "types.ts",
3345
+ corewire_exe: *std.Build.Step.Compile,
3346
+ spec: ExternalCoreFixtureSpec,
3347
+ ) ExternalCoreFixture {
3348
+ // The frontend, in check-only mode: the subset checker gates the
3349
+ // compile, and the contract sidecar states the build-root-relative
3350
+ // entry spelling. The frontend reads its own sources, the SDK
3351
+ // modules, and the core's WHOLE import graph at run time; declare
3352
+ // them all so edits re-check the fixture (every sibling .ts of the
3353
+ // entry is a superset of the reachable imports: over-approximation
3354
+ // only re-runs the check, never misses a stale input).
3355
+ const check = b.addSystemCommand(&.{node});
3356
+ check.addFileArg(b.path("packages/core/src/cli.ts"));
3357
+ check.addFileArg(b.path(spec.entry));
3358
+ check.addArg("--contract");
3359
+ const contract = check.addOutputFileArg("core.contract.json");
3360
+ check.addArg("--contract-entry");
3361
+ check.addArg(spec.entry);
3362
+ tsCoreAddDirInputs(b, check, "packages/core/sdk");
3363
+ tsCoreAddDirInputs(b, check, std.fs.path.dirname(spec.entry) orelse ".");
3364
+ const frontend_sources = [_][]const u8{
3365
+ "checker.ts", "cli.ts", "contract.ts", "diagnostics.ts", "frontend.ts", "infer.ts", "modules.ts", "typed_ast.ts", "types.ts", "wyhash.ts",
3455
3366
  };
3456
- for (transpiler_sources) |source| {
3457
- transpile.addFileInput(b.path(b.fmt("packages/core/src/{s}", .{source})));
3367
+ for (frontend_sources) |source| {
3368
+ check.addFileInput(b.path(b.fmt("packages/core/src/{s}", .{source})));
3458
3369
  }
3459
3370
 
3460
- // The emitted core imports "rt.zig" relatively: stage both files
3461
- // into one generated directory to root the fixture module there.
3371
+ // corewire projects the generated compile entry and its profile in
3372
+ // one invocation, so the profile's entry spelling and the facade
3373
+ // file can never skew.
3374
+ const project = b.addRunArtifact(corewire_exe);
3375
+ project.addArg("--sidecar");
3376
+ project.addFileArg(contract);
3377
+ project.addArg("--facade");
3378
+ const facade = project.addOutputFileArg("core_facade.ts");
3379
+ project.addArg("--profile");
3380
+ const profile = project.addOutputFileArg("core_profile.json");
3381
+ for (spec.f64_slots) |slot| {
3382
+ project.addArg("--f64-slot");
3383
+ project.addArg(slot);
3384
+ }
3385
+
3386
+ // The compile stage: author sources + staged SDK + static surface +
3387
+ // generated entry/profile, one scratch tree.
3388
+ const stage_run = b.addSystemCommand(&.{node});
3389
+ stage_run.addFileArg(b.path("packages/core/scripts/stage_external_core.mjs"));
3390
+ stage_run.addArg("--src");
3391
+ stage_run.addDirectoryArg(spec.src_dir);
3392
+ stage_run.addArg("--sdk");
3393
+ stage_run.addDirectoryArg(b.path("packages/core/sdk"));
3394
+ stage_run.addArg("--static");
3395
+ stage_run.addFileArg(b.path("packages/core/compile-surface/core.ts"));
3396
+ stage_run.addArg("--facade");
3397
+ stage_run.addFileArg(facade);
3398
+ stage_run.addArg("--profile");
3399
+ stage_run.addFileArg(profile);
3400
+ stage_run.addArg("--out");
3401
+ const stage_dir = stage_run.addOutputDirectoryArg("stage");
3402
+
3403
+ // The external compile: driver-verified against the SDK's exact
3404
+ // pin, archive normalized, the co-emitted sidecar captured.
3405
+ const compile = b.addSystemCommand(&.{node});
3406
+ compile.addFileArg(b.path("packages/core/scripts/run_external_core_compiler.mjs"));
3407
+ compile.addArg("--stage");
3408
+ compile.addDirectoryArg(stage_dir);
3409
+ compile.addArgs(&.{ "--name", spec.name });
3410
+ compile.addArg("--manifest");
3411
+ compile.addFileArg(b.path("packages/core/package.json"));
3412
+ compile.addArg("--out-archive");
3413
+ const archive = compile.addOutputFileArg(b.fmt("lib{s}.a", .{spec.name}));
3414
+ compile.addArg("--out-sidecar");
3415
+ const compiled_sidecar = compile.addOutputFileArg("core.contract.json");
3416
+ if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER")) |override| {
3417
+ // The development override: point at any toolchain command; the
3418
+ // driver still refuses a release other than the SDK's pin.
3419
+ compile.addArgs(&.{ "--compiler", override });
3420
+ } else {
3421
+ compile.addArg("--compiler-js");
3422
+ compile.addFileArg(b.path("packages/core/node_modules/scriptc/dist/main.js"));
3423
+ }
3424
+
3425
+ // The mirror, generated from the archive's OWN co-emitted contract,
3426
+ // staged in the app lane's module shape with the archive linked
3427
+ // behind it (the compiler's runtime needs libc).
3428
+ const mirror = b.addRunArtifact(corewire_exe);
3429
+ mirror.addArg("--sidecar");
3430
+ mirror.addFileArg(compiled_sidecar);
3431
+ mirror.addArg("--out");
3432
+ const shim = mirror.addOutputFileArg("core_shim.zig");
3462
3433
  const staged = b.addWriteFiles();
3463
- const core_root = staged.addCopyFile(emitted_core, "core.zig");
3464
- _ = staged.addCopyFile(b.path("packages/core/rt/rt.zig"), "rt.zig");
3465
- return b.createModule(.{
3466
- .root_source_file = core_root,
3434
+ const shim_root = staged.addCopyFile(shim, "core.zig");
3435
+ _ = staged.addCopyFile(b.path("tools/corewire/shim_rt.zig"), "shim_rt.zig");
3436
+ _ = staged.addCopyFile(b.path("tools/corewire/core_abi.zig"), "core_abi.zig");
3437
+ const mod = b.createModule(.{
3438
+ .root_source_file = shim_root,
3467
3439
  .target = target,
3468
3440
  .optimize = optimize,
3469
3441
  });
3442
+ mod.link_libc = true;
3443
+ mod.addObjectFile(archive);
3444
+ return .{
3445
+ .module = mod,
3446
+ .contract = contract,
3447
+ .archive = archive,
3448
+ .sidecar = compiled_sidecar,
3449
+ };
3470
3450
  }
3471
3451
 
3472
3452
  /// Declare every .ts file in `dir_path` (relative to the build root) as a