fix(build): invalidate cores on SDK module edits

This commit is contained in:
Chris Tate
2026-08-17 20:35:48 -05:00
parent 935fa3ebe4
commit 681d7434bf
2 changed files with 24 additions and 6 deletions
+5
View File
@@ -844,6 +844,10 @@ pub fn build(b: *std.Build) void {
.{ .path = "build/app.zig", .pattern = "const contract = stabilizeGeneratedFile(b, contract_raw, \"core.contract.json\", build_trace);" },
.{ .path = "build/app.zig", .pattern = "break :services_contract stabilizeGeneratedFile(b, raw, \"services.contract.json\", build_trace);" },
.{ .path = "build/app.zig", .pattern = "addAppCoreTsDirInputs(b, stage_run, appPath(b, app_root, \"src\"));" },
.{ .path = "build/app.zig", .pattern = "addStagedCoreSdkInputs(b, dep.builder, stage_run);" },
.{ .path = "build/app.zig", .pattern = "for ([_][]const u8{ \"text.ts\", \"events.ts\" }) |source|" },
.{ .path = "build.zig", .pattern = "app_build.addStagedCoreSdkInputs(b, b, stage_run);" },
.{ .path = "packages/core/scripts/stage_external_core.mjs", .pattern = "for (const sdkFile of [\"text.ts\", \"events.ts\"])" },
.{ .path = "build/app.zig", .pattern = "if (std.mem.startsWith(u8, normalized, \"services/\")) continue;" },
.{ .path = "tools/corewire/emit_service.zig", .pattern = "native-sdk.services.abi.v3" },
.{ .path = "tools/corewire/emit_service.zig", .pattern = "implementation-only fingerprint" },
@@ -4042,6 +4046,7 @@ fn externalCoreFixtureModule(
stage_run.addFileArg(client);
}
tsCoreAddCoreDirInputs(b, stage_run, std.fs.path.dirname(spec.entry) orelse ".");
app_build.addStagedCoreSdkInputs(b, b, stage_run);
stage_run.addArg("--out");
const stage_dir = stage_run.addOutputDirectoryArg("stage");
+19 -6
View File
@@ -1112,13 +1112,14 @@ fn tsCoreStage(
stage_run.addFileArg(client);
}
// `addDirectoryArg` orders the stager after a generated directory but
// does not hash a source directory's recursively discovered contents.
// The old graph accidentally got core-source invalidation from changing
// producer cache paths. Now that generated ABI files are stabilized by
// content, state the author's actual core compile inputs explicitly.
// Services are excluded because stage_external_core.mjs excludes them;
// their implementation class has its own compile lane.
// does not hash a source directory's discovered contents. The old graph
// accidentally got core-source invalidation from changing producer cache
// paths. Now that generated ABI files are stabilized by content, state
// every source the stager copies explicitly: authored core files plus the
// two SDK implementation modules. Services are excluded because they have
// their own compile lane.
addAppCoreTsDirInputs(b, stage_run, appPath(b, app_root, "src"));
addStagedCoreSdkInputs(b, dep.builder, stage_run);
stage_run.addArg("--out");
const stage_dir = stage_run.addOutputDirectoryArg("stage");
@@ -1320,6 +1321,18 @@ fn addAppCoreTsDirInputs(b: *std.Build, stage: *std.Build.Step.Run, src_path: []
}
}
/// Declare the SDK implementation modules copied by
/// stage_external_core.mjs. A directory LazyPath supplies ordering only for
/// this source tree; these file inputs make implementation-only SDK edits
/// invalidate the staged tree and compiled core archive even when the public
/// contract remains byte-identical. Public for the repository fixture graph,
/// which exercises the same compiler boundary as app builds.
pub fn addStagedCoreSdkInputs(b: *std.Build, sdk_builder: *std.Build, stage: *std.Build.Step.Run) void {
for ([_][]const u8{ "text.ts", "events.ts" }) |source| {
stage.addFileInput(sdk_builder.path(b.fmt("packages/core/sdk/{s}", .{source})));
}
}
fn appHasServiceFiles(b: *std.Build, app_root: []const u8) bool {
const services_path = appPath(b, app_root, "src/services");
var dir = b.build_root.handle.openDir(b.graph.io, services_path, .{ .iterate = true }) catch return false;