@native-sdk/cli 0.7.2 → 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.
- package/build/app.zig +265 -65
- package/build/ts_run.mjs +6 -8
- package/build.zig +292 -349
- package/package.json +13 -11
- package/packages/core/compile-surface/core.ts +559 -0
- package/packages/core/package-lock.json +375 -12
- package/packages/core/package.json +9 -6
- package/packages/core/scripts/compiler_typecheck.mjs +58 -0
- package/packages/core/scripts/gen_case_tables.mjs +130 -0
- package/packages/core/scripts/gen_declarations.mjs +97 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +108 -0
- package/packages/core/scripts/stage_external_core.mjs +148 -0
- package/packages/core/sdk/core.d.ts +363 -0
- package/packages/core/sdk/events.d.ts +65 -0
- package/packages/core/sdk/text.d.ts +51 -0
- package/packages/core/src/checker.ts +3 -3
- package/packages/core/src/cli.ts +40 -38
- package/packages/core/src/contract.ts +749 -0
- package/packages/core/src/devhost.ts +4 -3
- package/packages/core/src/diagnostics.ts +5 -7
- package/packages/core/src/{transpile.ts → frontend.ts} +38 -50
- package/packages/core/src/infer.ts +1 -1
- package/packages/core/src/typed_ast.ts +16 -15
- package/packages/core/src/wyhash.ts +79 -0
- package/skill-data/ts-core/SKILL.md +29 -29
- package/src/runtime/ts_core_host.zig +38 -38
- package/src/runtime/ts_ui_app.zig +12 -12
- package/src/tooling/manifest.zig +32 -0
- package/src/tooling/raw_manifest.zig +4 -0
- package/src/tooling/templates.zig +25 -20
- package/src/tooling/ts_core.zig +55 -34
- package/src/tooling/verbs.zig +1 -1
- package/tools/corewire/core_abi.zig +169 -0
- package/tools/corewire/emit.zig +2418 -0
- package/tools/corewire/emit_facade.zig +3984 -0
- package/tools/corewire/emit_profile.zig +501 -0
- package/tools/corewire/main.zig +561 -0
- package/tools/corewire/shim_rt.zig +632 -0
- package/tools/corewire/sidecar.zig +2507 -0
- package/packages/core/rt/rt.zig +0 -1986
- 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 —
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
//
|
|
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
|
-
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
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
|
|
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", "
|
|
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
|
-
//
|
|
501
|
-
//
|
|
502
|
-
//
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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
|
|
521
|
-
// generated entry module, and the
|
|
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);
|
|
@@ -570,7 +557,7 @@ pub fn build(b: *std.Build) void {
|
|
|
570
557
|
.{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "export type NativeSdkGpuSurfaceBackendRequest = \"metal\" | \"software\";" },
|
|
571
558
|
.{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "gpuBackend?: NativeSdkGpuSurfaceBackendRequest;" },
|
|
572
559
|
});
|
|
573
|
-
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
|
|
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)", &.{
|
|
574
561
|
// The resolution twins probe the aliased REAL compiler
|
|
575
562
|
// (@typescript/old — the package typed_ast.ts and ts_run.mjs
|
|
576
563
|
// actually load) — manifest AND entrypoint, in lockstep. The
|
|
@@ -585,9 +572,9 @@ pub fn build(b: *std.Build) void {
|
|
|
585
572
|
// only what runtime loads, from runtime's own walk origin, and
|
|
586
573
|
// leave the declared-but-unimported wrapper out of the verdict.
|
|
587
574
|
.{ .path = "src/tooling/ts_core.zig", .pattern = "Validation tracks ONLY what runtime loads" },
|
|
588
|
-
.{ .path = "src/tooling/ts_core.zig", .pattern = "
|
|
575
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "deliberately NOT probed" },
|
|
589
576
|
.{ .path = "build/app.zig", .pattern = "Validation tracks ONLY what runtime loads" },
|
|
590
|
-
.{ .path = "build/app.zig", .pattern = "
|
|
577
|
+
.{ .path = "build/app.zig", .pattern = "deliberately NOT probed" },
|
|
591
578
|
// The reciprocal cross-references that keep the twins findable
|
|
592
579
|
// from each other.
|
|
593
580
|
.{ .path = "src/tooling/ts_core.zig", .pattern = "build/app.zig's tsToolchainResolution" },
|
|
@@ -2988,6 +2975,10 @@ fn testArtifact(b: *std.Build, mod: *std.Build.Module) *std.Build.Step.Compile {
|
|
|
2988
2975
|
/// installed dependency (`npm ci` in packages/core) is missing.
|
|
2989
2976
|
const TsCoreE2eArtifacts = struct {
|
|
2990
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,
|
|
2991
2982
|
soundboard: *std.Build.Step.Compile,
|
|
2992
2983
|
system_monitor: *std.Build.Step.Compile,
|
|
2993
2984
|
/// The stock-IDE contract: a fresh scaffold (and the committed TS
|
|
@@ -2995,37 +2986,22 @@ const TsCoreE2eArtifacts = struct {
|
|
|
2995
2986
|
/// paths, and builds keep working with node_modules deleted.
|
|
2996
2987
|
scaffold_ide: *std.Build.Step.Compile,
|
|
2997
2988
|
ai_chat: *std.Build.Step.Compile,
|
|
2998
|
-
/// Sidecar-shim conformance (tests/sidecar): every fixture
|
|
2999
|
-
///
|
|
3000
|
-
///
|
|
3001
|
-
///
|
|
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.
|
|
3002
2993
|
sidecar_conformance: *std.Build.Step.Compile,
|
|
3003
|
-
///
|
|
3004
|
-
///
|
|
3005
|
-
/// (
|
|
3006
|
-
///
|
|
3007
|
-
|
|
3008
|
-
external_core_parity: ?*std.Build.Step.Compile,
|
|
3009
|
-
/// The full-corpus compiled-core batteries: each entry is one
|
|
3010
|
-
/// fixture app's OWN e2e suite compiled over a paired core — the
|
|
3011
|
-
/// transpiled lane plus a generated mirror dispatching into a
|
|
3012
|
-
/// caller-supplied compiled-core archive, byte-compared at every
|
|
3013
|
-
/// seam. Built per fixture only when its archive/sidecar env pair
|
|
3014
|
-
/// (NATIVE_SDK_EXTERNAL_CORE_ARCHIVE_<FIXTURE> and
|
|
3015
|
-
/// NATIVE_SDK_EXTERNAL_CORE_SIDECAR_<FIXTURE>) is supplied; empty
|
|
3016
|
-
/// — every battery skipped — otherwise.
|
|
3017
|
-
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,
|
|
3018
2999
|
/// Per-fixture contract artifacts for an external core toolchain:
|
|
3019
3000
|
/// the effective contract sidecar and its TypeScript facade/profile
|
|
3020
3001
|
/// projections, installed by the stage-core-contracts step.
|
|
3021
3002
|
core_contracts: []const CoreContract,
|
|
3022
3003
|
};
|
|
3023
3004
|
|
|
3024
|
-
const CompiledCoreParity = struct {
|
|
3025
|
-
name: []const u8,
|
|
3026
|
-
tests: *std.Build.Step.Compile,
|
|
3027
|
-
};
|
|
3028
|
-
|
|
3029
3005
|
const CoreContract = struct {
|
|
3030
3006
|
name: []const u8,
|
|
3031
3007
|
sidecar: std.Build.LazyPath,
|
|
@@ -3033,34 +3009,6 @@ const CoreContract = struct {
|
|
|
3033
3009
|
profile: std.Build.LazyPath,
|
|
3034
3010
|
};
|
|
3035
3011
|
|
|
3036
|
-
/// One fixture's compiled-core supply: the archive link input(s) and
|
|
3037
|
-
/// the archive's own emitted contract sidecar. Both come as a pair —
|
|
3038
|
-
/// a real archive's build_id can only match its co-emitted sidecar, so
|
|
3039
|
-
/// one without the other is a misconfiguration, refused with a
|
|
3040
|
-
/// teaching rather than skipped into silence.
|
|
3041
|
-
const CompiledCoreSupply = struct {
|
|
3042
|
-
archives: []const u8,
|
|
3043
|
-
sidecar: std.Build.LazyPath,
|
|
3044
|
-
};
|
|
3045
|
-
|
|
3046
|
-
fn compiledCoreEnv(b: *std.Build, comptime suffix: []const u8) ?CompiledCoreSupply {
|
|
3047
|
-
const archive_var = "NATIVE_SDK_EXTERNAL_CORE_ARCHIVE_" ++ suffix;
|
|
3048
|
-
const sidecar_var = "NATIVE_SDK_EXTERNAL_CORE_SIDECAR_" ++ suffix;
|
|
3049
|
-
const archives = b.graph.environ_map.get(archive_var);
|
|
3050
|
-
const sidecar = b.graph.environ_map.get(sidecar_var);
|
|
3051
|
-
if (archives == null and sidecar == null) return null;
|
|
3052
|
-
if (archives == null or sidecar == null) {
|
|
3053
|
-
std.debug.panic(
|
|
3054
|
-
"{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",
|
|
3055
|
-
.{ archive_var, sidecar_var },
|
|
3056
|
-
);
|
|
3057
|
-
}
|
|
3058
|
-
return .{
|
|
3059
|
-
.archives = b.dupe(archives.?),
|
|
3060
|
-
.sidecar = .{ .cwd_relative = b.dupe(sidecar.?) },
|
|
3061
|
-
};
|
|
3062
|
-
}
|
|
3063
|
-
|
|
3064
3012
|
fn tsCoreE2eArtifact(
|
|
3065
3013
|
b: *std.Build,
|
|
3066
3014
|
target: std.Build.ResolvedTarget,
|
|
@@ -3069,28 +3017,85 @@ fn tsCoreE2eArtifact(
|
|
|
3069
3017
|
tooling_mod: *std.Build.Module,
|
|
3070
3018
|
) ?TsCoreE2eArtifacts {
|
|
3071
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).
|
|
3072
3024
|
b.build_root.handle.access(
|
|
3073
3025
|
b.graph.io,
|
|
3074
|
-
"packages/core/node_modules/@typescript/
|
|
3026
|
+
"packages/core/node_modules/@typescript/old",
|
|
3075
3027
|
.{},
|
|
3076
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
|
+
});
|
|
3077
3050
|
|
|
3078
|
-
// Each fixture
|
|
3079
|
-
//
|
|
3080
|
-
//
|
|
3081
|
-
|
|
3082
|
-
|
|
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;
|
|
3083
3078
|
|
|
3084
3079
|
const e2e_mod = module(b, target, optimize, "tests/ts-core/host_e2e_tests.zig");
|
|
3085
3080
|
e2e_mod.addImport("native_sdk", desktop_mod);
|
|
3086
3081
|
e2e_mod.addImport("ts_core_fixture", fixture_mod);
|
|
3087
|
-
|
|
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);
|
|
3088
3088
|
|
|
3089
3089
|
// The soundboard-ts example's core and markup, tested as one app:
|
|
3090
3090
|
// the test root stages beside a copy of the example's app.native so
|
|
3091
3091
|
// the compiled markup engine builds the SHIPPING view over the
|
|
3092
|
-
//
|
|
3093
|
-
const
|
|
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;
|
|
3094
3099
|
const soundboard_stage = b.addWriteFiles();
|
|
3095
3100
|
const soundboard_root = soundboard_stage.addCopyFile(b.path("tests/ts-core/soundboard_e2e_tests.zig"), "soundboard_e2e_tests.zig");
|
|
3096
3101
|
_ = soundboard_stage.addCopyFile(b.path("examples/soundboard-ts/src/app.native"), "app.native");
|
|
@@ -3105,7 +3110,12 @@ fn tsCoreE2eArtifact(
|
|
|
3105
3110
|
// The system-monitor-ts example's core and markup, tested the same
|
|
3106
3111
|
// way — plus the ORIGINAL Zig example's committed sampler captures,
|
|
3107
3112
|
// staged as fixtures so both ports parse the same recorded truth.
|
|
3108
|
-
const
|
|
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;
|
|
3109
3119
|
const monitor_stage = b.addWriteFiles();
|
|
3110
3120
|
const monitor_root = monitor_stage.addCopyFile(b.path("tests/ts-core/system_monitor_e2e_tests.zig"), "system_monitor_e2e_tests.zig");
|
|
3111
3121
|
_ = monitor_stage.addCopyFile(b.path("examples/system-monitor-ts/src/app.native"), "app.native");
|
|
@@ -3129,7 +3139,12 @@ fn tsCoreE2eArtifact(
|
|
|
3129
3139
|
// The ai-chat-ts example's core and markup, tested the same way:
|
|
3130
3140
|
// the chat client for an OpenAI-compatible endpoint, driven through
|
|
3131
3141
|
// the fake fetch feed (no network) with its shipping markup.
|
|
3132
|
-
const
|
|
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;
|
|
3133
3148
|
const ai_chat_stage = b.addWriteFiles();
|
|
3134
3149
|
const ai_chat_root = ai_chat_stage.addCopyFile(b.path("tests/ts-core/ai_chat_e2e_tests.zig"), "ai_chat_e2e_tests.zig");
|
|
3135
3150
|
_ = ai_chat_stage.addCopyFile(b.path("examples/ai-chat-ts/src/app.native"), "app.native");
|
|
@@ -3141,58 +3156,42 @@ fn tsCoreE2eArtifact(
|
|
|
3141
3156
|
ai_chat_mod.addImport("native_sdk", desktop_mod);
|
|
3142
3157
|
ai_chat_mod.addImport("ts_ai_chat_core", ai_chat_core_mod);
|
|
3143
3158
|
|
|
3144
|
-
// Sidecar-shim conformance:
|
|
3145
|
-
//
|
|
3146
|
-
//
|
|
3147
|
-
//
|
|
3148
|
-
//
|
|
3149
|
-
// sidecars.
|
|
3150
|
-
const corewire_mod = b.createModule(.{
|
|
3151
|
-
.root_source_file = b.path("tools/corewire/main.zig"),
|
|
3152
|
-
.target = target,
|
|
3153
|
-
.optimize = optimize,
|
|
3154
|
-
});
|
|
3155
|
-
const corewire_exe = b.addExecutable(.{
|
|
3156
|
-
.name = "corewire",
|
|
3157
|
-
.root_module = corewire_mod,
|
|
3158
|
-
.use_llvm = @import("build/app.zig").useLlvmWorkaround(target),
|
|
3159
|
-
});
|
|
3160
|
-
const extract_mod = module(b, target, optimize, "tools/corewire/extract.zig");
|
|
3161
|
-
|
|
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.
|
|
3162
3164
|
const conformance_mod = module(b, target, optimize, "tests/sidecar/conformance_tests.zig");
|
|
3163
3165
|
conformance_mod.addImport("native_sdk", desktop_mod);
|
|
3164
3166
|
// The canonical value encoder the envelope and snapshot axes compare
|
|
3165
3167
|
// against (the same module the generated shims stage).
|
|
3166
3168
|
conformance_mod.addImport("corewire_rt", module(b, target, optimize, "tools/corewire/shim_rt.zig"));
|
|
3167
|
-
conformance_mod.addImport("ts_markup_core", markup_fixture_mod);
|
|
3168
3169
|
conformance_mod.addImport("shim_markup_core", sidecarShimModule(b, target, optimize, corewire_exe, b.path("tests/sidecar/markup_fixture.contract.json")));
|
|
3169
3170
|
// The integer-class fixture: a hand-written sidecar attesting mixed
|
|
3170
3171
|
// i64/u64 slot classes, so the suite drives boundary and full-range
|
|
3171
3172
|
// integer values through a generated mirror's decode paths.
|
|
3172
3173
|
conformance_mod.addImport("shim_integer_core", sidecarShimModule(b, target, optimize, corewire_exe, b.path("tests/sidecar/integer_fixture.contract.json")));
|
|
3173
3174
|
const conformance_fixtures = [_]struct {
|
|
3174
|
-
ts_import: []const u8,
|
|
3175
3175
|
shim_import: []const u8,
|
|
3176
3176
|
contract_name: []const u8,
|
|
3177
|
-
|
|
3178
|
-
entry: []const u8,
|
|
3177
|
+
core: ExternalCoreFixture,
|
|
3179
3178
|
/// Attested integer slots the compiled projection carries as f64
|
|
3180
3179
|
/// (values that reach the f64-exact boundary have no honest i64
|
|
3181
3180
|
/// declaration on that side).
|
|
3182
3181
|
f64_slots: []const []const u8 = &.{},
|
|
3183
3182
|
}{
|
|
3184
|
-
.{ .
|
|
3185
|
-
.{ .
|
|
3186
|
-
.{ .
|
|
3187
|
-
.{ .
|
|
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 },
|
|
3188
3187
|
};
|
|
3189
3188
|
// The corpus contract artifacts an external core toolchain consumes
|
|
3190
3189
|
// (stage-core-contracts): the effective sidecar plus its generated
|
|
3191
|
-
// entry module and compiler profile, per fixture.
|
|
3190
|
+
// entry module and compiler profile, per fixture. Every corewire
|
|
3191
|
+
// consumer reads the FRONTEND-emitted contract.
|
|
3192
3192
|
var core_contracts: std.ArrayList(CoreContract) = .empty;
|
|
3193
3193
|
{
|
|
3194
|
-
const
|
|
3195
|
-
const projections = facadeProjections(b, corewire_exe, markup_sidecar, &.{});
|
|
3194
|
+
const projections = facadeProjections(b, corewire_exe, markup_fixture.contract, &.{});
|
|
3196
3195
|
core_contracts.append(b.allocator, .{
|
|
3197
3196
|
.name = "markup-fixture",
|
|
3198
3197
|
.sidecar = projections.sidecar,
|
|
@@ -3201,10 +3200,8 @@ fn tsCoreE2eArtifact(
|
|
|
3201
3200
|
}) catch @panic("OOM");
|
|
3202
3201
|
}
|
|
3203
3202
|
for (conformance_fixtures) |fixture| {
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
conformance_mod.addImport(fixture.shim_import, sidecarShimModule(b, target, optimize, corewire_exe, sidecar_json));
|
|
3207
|
-
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);
|
|
3208
3205
|
core_contracts.append(b.allocator, .{
|
|
3209
3206
|
.name = fixture.contract_name,
|
|
3210
3207
|
.sidecar = projections.sidecar,
|
|
@@ -3213,161 +3210,34 @@ fn tsCoreE2eArtifact(
|
|
|
3213
3210
|
}) catch @panic("OOM");
|
|
3214
3211
|
}
|
|
3215
3212
|
|
|
3216
|
-
//
|
|
3217
|
-
//
|
|
3218
|
-
//
|
|
3219
|
-
//
|
|
3220
|
-
//
|
|
3221
|
-
//
|
|
3222
|
-
//
|
|
3223
|
-
//
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
const external_core_parity: ?*std.Build.Step.Compile = if (b.graph.environ_map.get("NATIVE_SDK_EXTERNAL_CORE_ARCHIVE")) |archives| blk: {
|
|
3231
|
-
const parity_mod = module(b, target, optimize, "tests/sidecar/external_core_parity_tests.zig");
|
|
3232
|
-
parity_mod.link_libc = true;
|
|
3233
|
-
parity_mod.addImport("corewire_rt", module(b, target, optimize, "tools/corewire/shim_rt.zig"));
|
|
3234
|
-
parity_mod.addImport("core_abi", module(b, target, optimize, "tools/corewire/core_abi.zig"));
|
|
3235
|
-
parity_mod.addImport("ts_core", markup_fixture_mod);
|
|
3236
|
-
const parity_sidecar: std.Build.LazyPath = if (b.graph.environ_map.get("NATIVE_SDK_EXTERNAL_CORE_SIDECAR")) |sidecar|
|
|
3237
|
-
.{ .cwd_relative = b.dupe(sidecar) }
|
|
3238
|
-
else
|
|
3239
|
-
b.path("tests/sidecar/markup_fixture.contract.json");
|
|
3240
|
-
parity_mod.addImport("shim_core", sidecarShimModule(b, target, optimize, corewire_exe, parity_sidecar));
|
|
3241
|
-
var inputs = std.mem.tokenizeScalar(u8, archives, std.fs.path.delimiter);
|
|
3242
|
-
while (inputs.next()) |input| {
|
|
3243
|
-
parity_mod.addObjectFile(.{ .cwd_relative = b.dupe(input) });
|
|
3244
|
-
}
|
|
3245
|
-
// The generated mirror is the only projection this lane uses;
|
|
3246
|
-
// sidecarShimModule validates exactly that surface. Do not run
|
|
3247
|
-
// the all-projections checker here: an external compiler's
|
|
3248
|
-
// sidecar may legitimately predate facade-only metadata while
|
|
3249
|
-
// remaining a valid mirror contract for its linked archive.
|
|
3250
|
-
break :blk filteredTestArtifact(b, parity_mod, "external-core-parity-tests", &.{});
|
|
3251
|
-
} else null;
|
|
3252
|
-
|
|
3253
|
-
// The full-corpus compiled-core batteries: each supplied fixture's
|
|
3254
|
-
// OWN e2e test root recompiled over a paired core (the transpiled
|
|
3255
|
-
// lane plus a fresh generated mirror linked against the caller's
|
|
3256
|
-
// archive), so every behavioral assertion the fixture app carries
|
|
3257
|
-
// runs through the compiled core with byte parity checked at every
|
|
3258
|
-
// seam (commands, snapshots, subscriptions, channels, helpers).
|
|
3259
|
-
// Env-gated per fixture like the markup parity suite: unset means
|
|
3260
|
-
// the battery is never built and `zig build test` stays green.
|
|
3261
|
-
var compiled_core_parity: std.ArrayList(CompiledCoreParity) = .empty;
|
|
3262
|
-
const compiled_core_fixtures = [_]struct {
|
|
3263
|
-
name: []const u8,
|
|
3264
|
-
supply: ?CompiledCoreSupply,
|
|
3265
|
-
ts_mod: *std.Build.Module,
|
|
3266
|
-
root: std.Build.LazyPath,
|
|
3267
|
-
core_import: []const u8,
|
|
3268
|
-
/// The host suite's second lane (the markup fixture) rides the
|
|
3269
|
-
/// same binary, transpiler-only: one archive per process is the
|
|
3270
|
-
/// compiled-core contract.
|
|
3271
|
-
second_import: ?[]const u8 = null,
|
|
3272
|
-
second_mod: ?*std.Build.Module = null,
|
|
3273
|
-
}{
|
|
3274
|
-
.{ .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 },
|
|
3275
|
-
// The markup battery is the mirror image of the host one: the
|
|
3276
|
-
// markup fixture's core pairs, and the host fixture rides along
|
|
3277
|
-
// transpiler-only as the second lane.
|
|
3278
|
-
.{ .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 },
|
|
3279
|
-
.{ .name = "soundboard", .supply = compiledCoreEnv(b, "SOUNDBOARD"), .ts_mod = soundboard_core_mod, .root = soundboard_root, .core_import = "ts_soundboard_core" },
|
|
3280
|
-
.{ .name = "system-monitor", .supply = compiledCoreEnv(b, "SYSTEM_MONITOR"), .ts_mod = monitor_core_mod, .root = monitor_root, .core_import = "ts_system_monitor_core" },
|
|
3281
|
-
.{ .name = "ai-chat", .supply = compiledCoreEnv(b, "AI_CHAT"), .ts_mod = ai_chat_core_mod, .root = ai_chat_root, .core_import = "ts_ai_chat_core" },
|
|
3282
|
-
};
|
|
3283
|
-
for (compiled_core_fixtures) |entry| {
|
|
3284
|
-
const supply = entry.supply orelse continue;
|
|
3285
|
-
const paired_mod = pairedCoreModule(b, target, optimize, corewire_exe, entry.ts_mod, supply);
|
|
3286
|
-
const battery_mod = b.createModule(.{
|
|
3287
|
-
.root_source_file = entry.root,
|
|
3288
|
-
.target = target,
|
|
3289
|
-
.optimize = optimize,
|
|
3290
|
-
});
|
|
3291
|
-
battery_mod.addImport("native_sdk", desktop_mod);
|
|
3292
|
-
battery_mod.addImport(entry.core_import, paired_mod);
|
|
3293
|
-
if (entry.second_import) |second| battery_mod.addImport(second, entry.second_mod.?);
|
|
3294
|
-
const battery = filteredTestArtifact(b, battery_mod, b.fmt("compiled-core-{s}-tests", .{entry.name}), &.{});
|
|
3295
|
-
compiled_core_parity.append(b.allocator, .{ .name = b.dupe(entry.name), .tests = battery }) catch @panic("OOM");
|
|
3296
|
-
}
|
|
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);
|
|
3297
3227
|
|
|
3298
3228
|
return .{
|
|
3299
3229
|
.host = filteredTestArtifact(b, e2e_mod, "ts-core-e2e-tests", &.{}),
|
|
3230
|
+
.markup = filteredTestArtifact(b, markup_e2e_mod, "ts-markup-e2e-tests", &.{}),
|
|
3300
3231
|
.soundboard = filteredTestArtifact(b, soundboard_mod, "ts-soundboard-e2e-tests", &.{}),
|
|
3301
3232
|
.system_monitor = filteredTestArtifact(b, monitor_mod, "ts-system-monitor-e2e-tests", &.{}),
|
|
3302
3233
|
.scaffold_ide = filteredTestArtifact(b, scaffold_ide_mod, "ts-scaffold-ide-e2e-tests", &.{}),
|
|
3303
3234
|
.ai_chat = filteredTestArtifact(b, ai_chat_mod, "ts-ai-chat-e2e-tests", &.{}),
|
|
3304
3235
|
.sidecar_conformance = filteredTestArtifact(b, conformance_mod, "sidecar-conformance-tests", &.{}),
|
|
3305
|
-
.
|
|
3306
|
-
.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", &.{}),
|
|
3307
3237
|
.core_contracts = core_contracts.toOwnedSlice(b.allocator) catch @panic("OOM"),
|
|
3308
3238
|
};
|
|
3309
3239
|
}
|
|
3310
3240
|
|
|
3311
|
-
/// One fixture's paired-core module (tests/compiled-core): generate
|
|
3312
|
-
/// the lockstep root from the transpiled module's own export surface,
|
|
3313
|
-
/// stage it beside the pairing library and the mirror-value converter,
|
|
3314
|
-
/// bind the transpiled lane and a mirror generated from the supplied
|
|
3315
|
-
/// contract sidecar, and link the caller's compiled-core archive(s).
|
|
3316
|
-
fn pairedCoreModule(
|
|
3317
|
-
b: *std.Build,
|
|
3318
|
-
target: std.Build.ResolvedTarget,
|
|
3319
|
-
optimize: std.builtin.OptimizeMode,
|
|
3320
|
-
corewire_exe: *std.Build.Step.Compile,
|
|
3321
|
-
ts_mod: *std.Build.Module,
|
|
3322
|
-
supply: CompiledCoreSupply,
|
|
3323
|
-
) *std.Build.Module {
|
|
3324
|
-
const gen_root = b.addWriteFiles().add("gen_paired_main.zig",
|
|
3325
|
-
\\//! Generated by the build: emit a fixture's paired-core root
|
|
3326
|
-
\\//! from its transpiled module (tests/compiled-core/gen_paired.zig).
|
|
3327
|
-
\\const std = @import("std");
|
|
3328
|
-
\\const gen = @import("gen_paired");
|
|
3329
|
-
\\const core = @import("ts_core");
|
|
3330
|
-
\\pub fn main(init: std.process.Init) !void {
|
|
3331
|
-
\\ try gen.emitMain(core, init);
|
|
3332
|
-
\\}
|
|
3333
|
-
\\
|
|
3334
|
-
);
|
|
3335
|
-
const gen_mod = b.createModule(.{
|
|
3336
|
-
.root_source_file = gen_root,
|
|
3337
|
-
.target = target,
|
|
3338
|
-
.optimize = optimize,
|
|
3339
|
-
});
|
|
3340
|
-
gen_mod.addImport("gen_paired", module(b, target, optimize, "tests/compiled-core/gen_paired.zig"));
|
|
3341
|
-
gen_mod.addImport("ts_core", ts_mod);
|
|
3342
|
-
const gen_exe = b.addExecutable(.{
|
|
3343
|
-
.name = "gen-paired",
|
|
3344
|
-
.root_module = gen_mod,
|
|
3345
|
-
.use_llvm = @import("build/app.zig").useLlvmWorkaround(target),
|
|
3346
|
-
});
|
|
3347
|
-
const gen_run = b.addRunArtifact(gen_exe);
|
|
3348
|
-
const paired_src = gen_run.addOutputFileArg("paired.zig");
|
|
3349
|
-
|
|
3350
|
-
const staged = b.addWriteFiles();
|
|
3351
|
-
const paired_root = staged.addCopyFile(paired_src, "paired.zig");
|
|
3352
|
-
_ = staged.addCopyFile(b.path("tests/compiled-core/paired_core.zig"), "paired_core.zig");
|
|
3353
|
-
_ = staged.addCopyFile(b.path("tests/sidecar/mirror_value.zig"), "mirror_value.zig");
|
|
3354
|
-
const mod = b.createModule(.{
|
|
3355
|
-
.root_source_file = paired_root,
|
|
3356
|
-
.target = target,
|
|
3357
|
-
.optimize = optimize,
|
|
3358
|
-
});
|
|
3359
|
-
mod.link_libc = true;
|
|
3360
|
-
mod.addImport("ts_lane", ts_mod);
|
|
3361
|
-
mod.addImport("shim_lane", sidecarShimModule(b, target, optimize, corewire_exe, supply.sidecar));
|
|
3362
|
-
mod.addImport("corewire_rt", module(b, target, optimize, "tools/corewire/shim_rt.zig"));
|
|
3363
|
-
mod.addImport("core_abi", module(b, target, optimize, "tools/corewire/core_abi.zig"));
|
|
3364
|
-
var inputs = std.mem.tokenizeScalar(u8, supply.archives, std.fs.path.delimiter);
|
|
3365
|
-
while (inputs.next()) |input| {
|
|
3366
|
-
mod.addObjectFile(.{ .cwd_relative = b.dupe(input) });
|
|
3367
|
-
}
|
|
3368
|
-
return mod;
|
|
3369
|
-
}
|
|
3370
|
-
|
|
3371
3241
|
const FacadeProjections = struct {
|
|
3372
3242
|
sidecar: std.Build.LazyPath,
|
|
3373
3243
|
facade: std.Build.LazyPath,
|
|
@@ -3427,83 +3297,156 @@ fn sidecarShimModule(
|
|
|
3427
3297
|
});
|
|
3428
3298
|
}
|
|
3429
3299
|
|
|
3430
|
-
///
|
|
3431
|
-
///
|
|
3432
|
-
///
|
|
3433
|
-
///
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
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).
|
|
3440
3322
|
entry: []const u8,
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
, .{entry}));
|
|
3453
|
-
const mod = b.createModule(.{
|
|
3454
|
-
.root_source_file = root,
|
|
3455
|
-
.target = target,
|
|
3456
|
-
.optimize = optimize,
|
|
3457
|
-
});
|
|
3458
|
-
mod.addImport("extract", extract_mod);
|
|
3459
|
-
mod.addImport("ts_core", core_mod);
|
|
3460
|
-
const exe = b.addExecutable(.{
|
|
3461
|
-
.name = "sidecar-extract",
|
|
3462
|
-
.root_module = mod,
|
|
3463
|
-
.use_llvm = @import("build/app.zig").useLlvmWorkaround(target),
|
|
3464
|
-
});
|
|
3465
|
-
const run = b.addRunArtifact(exe);
|
|
3466
|
-
return run.addOutputFileArg("core.contract.json");
|
|
3467
|
-
}
|
|
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
|
+
};
|
|
3468
3334
|
|
|
3469
|
-
///
|
|
3470
|
-
///
|
|
3471
|
-
|
|
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(
|
|
3472
3341
|
b: *std.Build,
|
|
3473
3342
|
target: std.Build.ResolvedTarget,
|
|
3474
3343
|
optimize: std.builtin.OptimizeMode,
|
|
3475
3344
|
node: []const u8,
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
//
|
|
3484
|
-
//
|
|
3485
|
-
// re-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
const
|
|
3491
|
-
|
|
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",
|
|
3492
3366
|
};
|
|
3493
|
-
for (
|
|
3494
|
-
|
|
3367
|
+
for (frontend_sources) |source| {
|
|
3368
|
+
check.addFileInput(b.path(b.fmt("packages/core/src/{s}", .{source})));
|
|
3495
3369
|
}
|
|
3496
3370
|
|
|
3497
|
-
//
|
|
3498
|
-
//
|
|
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");
|
|
3499
3433
|
const staged = b.addWriteFiles();
|
|
3500
|
-
const
|
|
3501
|
-
_ = staged.addCopyFile(b.path("
|
|
3502
|
-
|
|
3503
|
-
|
|
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,
|
|
3504
3439
|
.target = target,
|
|
3505
3440
|
.optimize = optimize,
|
|
3506
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
|
+
};
|
|
3507
3450
|
}
|
|
3508
3451
|
|
|
3509
3452
|
/// Declare every .ts file in `dir_path` (relative to the build root) as a
|