summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 00:45:31 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commite699ffe4182f66e28180ea2d91ab1fb8c408d49e (patch)
tree0577374fb6164ef214cd727b662a23498ad547eb /build.zig
parenta1ae80096bd69ee7d92ea9e4564e960d8553395e (diff)
downloadsketchbook-e699ffe4182f66e28180ea2d91ab1fb8c408d49e.tar.gz
sketchbook-e699ffe4182f66e28180ea2d91ab1fb8c408d49e.zip
Delete the Store; State is checked against the 64 MiB a save holds
A sketch's data is State: flat bytes, what grows has its capacity in its type. The Store, a heap in a file mapped at 0x2000_0000_0000 with 64 GiB reserved, its power-of-two allocator, its root adopt and migration, and its test, are gone from memory.zig; so are Context.store and store_root, Info.store, Memory.store, the Store declaration's glue, Init.store, Frame.store and Console.store, the web host's store in wasm memory, the host's StoreFile wiring and `<state>.store` file, the `.store` suffix in moving an old state into .sketchbook/, the build's tests' `rm` of it, and layout.check's `pointers` flag (State is the one checked memory now). Its one real user, micscope, moved off it in the change before. Old `.state.store` files are not read, converted or deleted, and stay ignored by .gitignore. A sketch that still declares a Store gets no error for the declaration: nothing reads it, and a `*Store` parameter is a compile error (no argument of that type). layout.of(T, .state) refuses a State bigger than layout.max_state, 64 MiB, one constant: "State is N bytes, and a save holds at most 64 MiB: lower a capacity (an array, an sk.List), or keep what need not be saved in Session." The pointer-hash gap the spec found (a Store pointer's element type changing kept the old bytes) is gone with the only persisted memory that held pointers. README: no Store row, allocator row, migration paragraph, file bullet or known limits; draw and command lose their store parameter; State's row says 64 MiB at most; data that grows and is the user's work goes in a List in State or, bigger than a save, in files the sketch appends to. Tests: zig build test, 166/166 steps (the store's unit test gone; new: a 65-MiB State fails to compile with the message above, by expect_errors). micscope, spheres, noc's e2e and drat-meout's test unchanged and green. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig19
1 files changed, 14 insertions, 5 deletions
diff --git a/build.zig b/build.zig
index 02d312e..0367809 100644
--- a/build.zig
+++ b/build.zig
@@ -183,6 +183,15 @@ pub fn build(b: *Build) void {
b.createModule(.{ .root_source_file = b.path("src/math/root.zig"), .target = target, .optimize = optimize }),
b.createModule(.{ .root_source_file = b.path("src/host/root.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "abi", .module = abi }, .{ .name = "c", .module = c }, .{ .name = "gpu", .module = gpu }, .{ .name = "tracy", .module = tracy }, .{ .name = "cloud9", .module = cloud9 }, .{ .name = "xitdb", .module = xitdb } } }),
}) |module| test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module })).step);
+ // A State bigger than a save holds is a compile error that says what to do.
+ const too_big = b.addObject(.{ .name = "too_big", .root_module = b.createModule(.{
+ .root_source_file = b.addWriteFiles().add("too_big.zig", "comptime { _ = @import(\"abi\").layout.of(struct { bytes: [(64 << 20) + 1]u8 }, .state); }"),
+ .target = target,
+ .optimize = optimize,
+ .imports = &.{.{ .name = "abi", .module = abi }},
+ }) });
+ too_big.expect_errors = .{ .contains = "a save holds at most 64 MiB: lower a capacity (an array, an sk.List), or keep what need not be saved in Session." };
+ test_step.dependOn(&too_big.step);
// The anim module alone: its unit tests, and below the player's scenes.
const test_anim = b.step("test-anim", "Test the anim module: its unit tests and the player on its test scenes");
const anim_tests = b.addRunArtifact(b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/anim/root.zig"), .target = target, .optimize = optimize, .imports = anim_imports }) }));
@@ -386,11 +395,11 @@ pub fn build(b: *Build) void {
const killed = b.addSystemCommand(&.{ "sh", "-c",
\\set -e
\\db="${3%.state}.xitdb"
- \\rm -f "$3" "$3.store" "$db"
+ \\rm -f "$3" "$db"
\\if "$0" --headless --script "$1" --state "$3" "$4"; then echo "killed run exited"; exit 1; else test $? = 137; fi
\\"$0" --headless --script "$2" --state "$3" "$4"
\\test "$(stat -c %s "$db")" -lt 1048576
- \\rm -f "$3" "$3.store" "$db"
+ \\rm -f "$3" "$db"
});
killed.setName("a session survives kill -9");
killed.addArtifactArg(host_exe);
@@ -414,12 +423,12 @@ pub fn build(b: *Build) void {
const past = b.addSystemCommand(&.{ "sh", "-c",
\\set -e
\\db="${4%.state}.xitdb"
- \\rm -f "$4" "$4.store" "$db"
+ \\rm -f "$4" "$db"
\\"$0" --headless --script "$1" --state "$4" "$5"
\\"$0" --headless --script "$2" --state "$4" "$5"
\\"$0" --headless --script "$3" --state "$4" "$6"
\\test "$(stat -c %s "$db")" -lt 1048576
- \\rm -f "$4" "$4.store" "$db"
+ \\rm -f "$4" "$db"
});
past.setName("past sessions replay");
past.addArtifactArg(host_exe);
@@ -498,7 +507,7 @@ pub fn build(b: *Build) void {
\\test -s data/replay/replay.state; test -s data/replay/replay.xitdb
\\"$exe" --headless --state replay.state --console "set updates 7" --console quit "$lib"
\\"$exe" --headless --state .sketchbook/replay.state --console quit "$lib" 2>err
- \\grep -q moved err; test ! -e replay.state; test ! -e replay.state.store; grep -qx '*' .sketchbook/.gitignore
+ \\grep -q moved err; test ! -e replay.state; grep -qx '*' .sketchbook/.gitignore
\\printf 'expect updates 7\n' >check.script
\\"$exe" --headless --state .sketchbook/replay.state --script check.script "$lib"
\\"$exe" --headless --state replay.state --console quit "$lib"