From 4439d9a84f5945aefe90104eed6ff3f7d3292de7 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 13 Nov 2026 23:51:36 -0500 Subject: [PATCH] R1: Linux export pipeline (make dist, make dist-check) make dist (tools/dist.sh) checks the official export templates against tools/engine.sha512, installs only the Linux x86_64 ones into the repo-local engine data, exports the "Linux" preset, checks the binary is the verified release template, and packs build/dist/tidewall--linux-x86_64.tar.gz with a .sha256: tidewall.x86_64, tidewall.pck, a tidewall-server launcher that runs the same game headless with clean SIGTERM handling, an example server.cfg, README, VERSION, licences and asset provenance. BuildInfo gives the version (application/config/version, now 0.9.0) and the commit (build_commit.txt written by make dist, or .git in a checkout). The main menu shows "Version 0.9.0 (commit)" and the server's start log line carries version and commit. make dist-check (tools/dist_check.sh) unpacks the package outside the repo with HOME and XDG dirs in a temp dir and runs smoke against it (new SMOKE_DIST mode), a whole bot match, and the exported game joining the exported server over loopback. A release template crashes on a call on null (exit 139) and ignores invalid calls, so in package mode smoke's fault check expects only a non-zero exit. Closes #60 Co-Authored-By: Claude Opus 5.5 --- .gitignore | 3 + CLAUDE.md | 2 + Makefile | 12 +++- docs/DEVLOG.md | 49 ++++++++++++++ export_presets.cfg | 31 +++++++++ packaging/dist/README.md | 41 ++++++++++++ packaging/dist/tidewall-server | 39 ++++++++++++ project.godot | 1 + src/app/build_info.gd | 65 +++++++++++++++++++ src/app/build_info.gd.uid | 1 + src/server/headless_server.gd | 2 + src/ui/menus.gd | 7 ++ test/project/test_build_info.gd | 46 ++++++++++++++ test/project/test_build_info.gd.uid | 1 + test/ui/test_menus.gd | 7 ++ tools/dist.sh | 96 ++++++++++++++++++++++++++++ tools/dist_check.sh | 99 +++++++++++++++++++++++++++++ tools/smoke.sh | 40 +++++++++--- 18 files changed, 533 insertions(+), 9 deletions(-) create mode 100644 export_presets.cfg create mode 100644 packaging/dist/README.md create mode 100755 packaging/dist/tidewall-server create mode 100644 src/app/build_info.gd create mode 100644 src/app/build_info.gd.uid create mode 100644 test/project/test_build_info.gd create mode 100644 test/project/test_build_info.gd.uid create mode 100755 tools/dist.sh create mode 100755 tools/dist_check.sh diff --git a/.gitignore b/.gitignore index 8cf1d06..21ca8bd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ build/ captures/ *.log __pycache__/ + +# Written by make dist while exporting +build_commit.txt diff --git a/CLAUDE.md b/CLAUDE.md index ef15566..643d7a6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -47,6 +47,8 @@ continuity. | `make style-captures` | Renders a hamlet and a dock with and without the woodcut print pass (`captures/style_*.png`). Needs Docker. | | `make soak` | The 24-client network soak (N8): a real server and 24 headless `SoakPlayer` clients in three processes, each behind a `UdpRelay` adding 60 ms, +/-20 ms jitter and 2% loss each way, for two whole matches in real time (about 30 min, under `nice`). Fails on a world-hash mismatch, errors, unreadable packets, a client that didn't play every match, memory growth between matches, or a p99 tick over budget. `SOAK_MATCHES`, `SOAK_CLIENTS`, `SOAK_PROCS`, `SOAK_LATENCY`, `SOAK_JITTER`, `SOAK_LOSS` scale it. Results in `build/soak/report.txt`. | | `make bench` | H1: the server's p50/p99/max tick with 24 bots on three seeds, and the client's draw calls, triangles, objects and memory at six moments of a match (about 3 min, needs Docker). Fails on anything over the budgets in docs/ARCHITECTURE.md. Report in `build/bench/report.txt`. `BENCH_SEEDS`, `BENCH_TICKS`, `BENCH_CLIENT=0` scale it. | +| `make dist` | R1: exports the game with the official Godot templates (checked against `tools/engine.sha512`, installed into `.godot-home/`) to `build/dist/tidewall--linux-x86_64.tar.gz` with a `.sha256`. One binary and one pack: `tidewall.x86_64` is the game, `tidewall-server` runs it headless as the server. The version is `application/config/version` in project.godot; the commit goes in as `build_commit.txt` (`BuildInfo`). | +| `make dist-check` | R1: builds the package, unpacks it outside the repo with HOME and XDG dirs in a temp dir, and runs `SMOKE_DIST= tools/smoke.sh`, a whole bot match, and the exported game joining the exported server (about 2 min). | | `make soak-selfcheck` | About a minute: tampers with one client's world and checks the soak's comparison catches it and only it. | | `make server-package-check` | Builds the server image with `packaging/docker/compose.yaml`, waits for it to be healthy, checks it is non-root and read-only, joins it with a headless client and stops it with SIGTERM (N7, about 1.5 min). Needs Docker. See `packaging/README.md`. | | `make models` | Rebuilds every item model (`assets/models/items/*.obj`, with grip data in `.json`) and icon (`assets/icons/items/*.png`) from `tools/models/items.py` in headless Blender on the CPU. Materials are named after `Palette` colours; `ItemModels` paints them. | diff --git a/Makefile b/Makefile index eb9c200..6b35dfe 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Tidewall build entry points. Everything runs headless with the repo-local engine. GODOT := tools/godot.sh -.PHONY: bench build-captures poi-captures art figure figure-captures sea-captures models item-captures audio audio-check check import parse test test-selfcheck smoke capture-test terrain-capture binaries verify-engine bot-matches match match-captures client-check client-captures hud-captures style-captures menu-captures chart-captures discovery-check fuzz soak soak-selfcheck server-package-check +.PHONY: bench dist dist-check build-captures poi-captures art figure figure-captures sea-captures models item-captures audio audio-check check import parse test test-selfcheck smoke capture-test terrain-capture binaries verify-engine bot-matches match match-captures client-check client-captures hud-captures style-captures menu-captures chart-captures discovery-check fuzz soak soak-selfcheck server-package-check ## A8: regenerates every sound in assets/audio/ from tools/audio/ (about 6 s). audio: import @@ -46,6 +46,16 @@ item-captures: import bench: import @tools/bench.sh +## R1: exports the game with the official templates into +## build/dist/tidewall--linux-x86_64.tar.gz (about 20 s). +dist: import + @tools/dist.sh + +## R1: builds the package, unpacks it outside the repo, and runs smoke, a whole bot match +## and its game playing on its server there (about 2 minutes). +dist-check: import + @tools/dist_check.sh + ## Everything that must pass before a push. check: verify-engine binaries parse test test-selfcheck smoke diff --git a/docs/DEVLOG.md b/docs/DEVLOG.md index b9fd472..808e8b8 100644 --- a/docs/DEVLOG.md +++ b/docs/DEVLOG.md @@ -1089,3 +1089,52 @@ high-priority issues, and A3, A7, A12 and A13 deferred. - v0.9 has started. About 59 hours remain to Monday 08:00. **Next run:** H13 (the soak hash mismatch, the last v0.9 bug), then R1 (Linux export), which matters most for Monday. R1 depends on H1, so H1 (performance pass) should come before R1 or alongside it. + +## 2026-11-14 (night): H1 and R1 done, H13 still open + +**Start of run (23:03 ET Friday):** the lock was free and acquired fresh. The pull was a no-op and the tree was clean. The Agents category had nothing addressed to this task. + +**H13 (#80), still open:** I took the issue's two leads further by reading the code, but couldn't settle it without a recurrence. +- `StructureSet.write_state` hashes `_next_id`, and a provisional piece pushes the client's `_next_id` to 2^30. `NetWorld.world_hash` builds its own buffer without `_next_id`, so that difference isn't in the hash. Ruled out. +- `grounded` only depends on terrain and fixed solids, never on neighbouring pieces, so a provisional neighbour can't change a server piece's flag. Ruled out. +- Still open: `ClientWorld.tick` only ever rises. I found no path where it passes the snapshot's tick while `replica.seq == world_seq`. +- The diagnostics from 0ddcb48 will name the differing part the next time a soak hits it. + +**H1 (#54), closed: `make bench`.** +- `tools/bench.sh` and `tools/bench_report.gd`: + - the server with 24 bots, unthrottled, 12,000 ticks on seeds 2, 7 and 20261109; + - six client frames in the capture container, each reporting draw calls, shadow draws, primitives, objects, nodes, video and static memory. `tools/capture.gd` now adds a `render` field to every capture report. +- Budgets added to ARCHITECTURE: p99 tick 12 ms; 2,000 draw calls and 2,000,000 primitives per frame across all passes; 1 GiB video and 512 MiB static memory. +- **Before:** barge 2,197 draws (over budget), landed 612, built 613, final 815. **After:** barge 1,207, landed 430, built 457, final 685, with the same primitives. The fix: each figure part had one surface per colour, about 43 per figure, drawn again for shadows. `FigureRig` now merges each part into one surface per finish (coat, gilt, plain), with the colours as vertex colours (`vertex_color_is_srgb`). The figure close-up and the barge capture were opened and look the same. +- Server p50 is 0.53–0.66 ms and p99 1.9–2.1 ms. The max includes one tick of about 1.7 s per match, which is a bench artifact: unthrottled, the 15 s results screen passes in about 0.3 s, so the main thread waits for the worker building the next island. At 30 Hz the worker has 15 s. +- Real GPU frame rates are not measured (R6). + +**R1 (#60): Linux export.** +- `make dist` (`tools/dist.sh`): + - checks the export templates' SHA-512 against `tools/engine.sha512`, and installs only `linux_release.x86_64`, `linux_debug.x86_64` and `version.txt` into `.godot-home/` (not Eric's home); + - exports the `Linux` preset (`export_presets.cfg`, which leaves out test/, tools/, captures/, build/, docs/ and packaging/); + - checks the exported binary is byte-identical to the verified template; + - packs `build/dist/tidewall-0.9.0-linux-x86_64.tar.gz` (29 MB) with a `.sha256`, using sorted names, owner 0 and the commit's mtime. +- Package contents: + - `tidewall.x86_64` (73.5 MB, the official release template); + - `tidewall.pck` (2.7 MB: scripts, scenes, and the imported audio, models and icons); + - `tidewall-server` (runs the same binary and pack headless as the dedicated server, turning SIGTERM into a clean stop); + - `server.cfg` (example); + - `README.md` (play, server, files, licence; from `packaging/dist/`); + - `VERSION` (version, commit, engine); + - `LICENSE`, `LICENSE-ASSETS`, `PROVENANCE.md`. +- **Version and commit:** `application/config/version` in project.godot is now `0.9.0`. R5 makes it 1.0.0. `BuildInfo` reads the commit from `build_commit.txt` (written by `make dist` and git-ignored), or from `.git` when run from the checkout. The main menu shows "Version 0.9.0 (commit)", and the server's `start` log line carries `version` and `commit`. +- `make dist-check` (`tools/dist_check.sh`) unpacks the package in a temp dir with HOME and XDG in that dir, then: + - checks the sha256 and the exact file list; + - runs `SMOKE_DIST= tools/smoke.sh` (new mode), which gives state hash `3b20a907…`, the same as the repo build on the same seed; + - runs a whole bot match to results with 0 errors, with version and commit in the log matching VERSION; + - has the exported game join the exported server over loopback, playing 3,558 frames. +- **Decisions:** + - One preset, not two. Godot's dedicated-server export didn't strip anything by default here (the server pack came out the same size), so it was a duplicate. + - Release templates refuse `--main-pack`, so the launcher relies on the binary loading `tidewall.pck` beside it. +- **What I learned about release templates:** + - A GDScript call on null crashes the process (exit 139) instead of being reported. + - An invalid call on a real object is silently ignored. + - So the smoke fault check expects only a non-zero exit in package mode. + - The systemd unit already has `Restart=on-failure`. + - This makes the debug-only checks in `make check` and the soak the real guard for script errors. diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..549ca86 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,31 @@ +[preset.0] + +name="Linux" +platform="Linux" +runnable=true +advanced_options=false +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="build_commit.txt" +exclude_filter="test/*, tools/*, captures/*, build/*, docs/*, packaging/*, data/.gitkeep" +export_path="build/dist/stage/tidewall.x86_64" +patches=PackedStringArray() +encryption_include_filters="" +encryption_exclude_filters="" +seed=0 +encrypt_pck=false +encrypt_directory=false +script_export_mode=2 + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=0 +binary_format/embed_pck=false +texture_format/s3tc_bptc=true +texture_format/etc2_astc=false +shader_baker/enabled=false +binary_format/architecture="x86_64" +ssh_remote_deploy/enabled=false diff --git a/packaging/dist/README.md b/packaging/dist/README.md new file mode 100644 index 0000000..a4dfdc0 --- /dev/null +++ b/packaging/dist/README.md @@ -0,0 +1,41 @@ +# Tidewall for Linux (x86_64) + +A free and open-source build-and-survive battle royale. The sea rises in phases and +swallows the low ground, so the last dry land keeps getting higher and smaller. + +## Play + + ./tidewall.x86_64 + +The game opens on its main menu: practice against bots offline, or join a server on +your network or by address. It needs a Vulkan-capable GPU and driver (Forward+). On +hardware without Vulkan, start it with `--rendering-driver opengl3` to use OpenGL. + +Settings and key bindings are saved in `~/.local/share/godot/app_userdata/Tidewall/`. + +## Run a server + + ./tidewall-server --config=server.cfg + +`server.cfg` is an example: it takes players over UDP on port 24650, answers LAN +discovery on 24651, and fills empty places with bots. Every option can also be given +on the command line (`--port=24650`, `--bots=1`, `--name=...`). SIGTERM or Ctrl+C stops +the server cleanly. Logs are JSON lines on standard output. + +## What's here + +| File | | +|---|---| +| `tidewall.x86_64` | The Godot 4.7.2 engine (official release template) | +| `tidewall.pck` | The game | +| `tidewall-server` | Runs the same game headless as a dedicated server | +| `server.cfg` | Example server configuration | +| `VERSION` | Version, commit and engine | +| `PROVENANCE.md` | How every model, texture and sound was made | + +## Licence + +Code: GPL-3.0-or-later (`LICENSE`). Art and audio, all generated by scripts in the +source repository: CC BY-SA 4.0 (`LICENSE-ASSETS`). The Godot engine is MIT-licensed. + +Source: https://gitea.eom.dev/claude/tidewall diff --git a/packaging/dist/tidewall-server b/packaging/dist/tidewall-server new file mode 100755 index 0000000..3e56db2 --- /dev/null +++ b/packaging/dist/tidewall-server @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Runs a Tidewall dedicated server from the release package, headless, and turns +# SIGTERM or SIGINT into a clean stop: the server tells everyone connected it is +# shutting down, logs its statistics and exits 0. The engine can't catch signals +# itself, so this wrapper creates the server's --stop-file when one arrives, and kills +# the server only if it hasn't gone after TIDEWALL_STOP_SECONDS (default 15). +# +# ./tidewall-server [server options...] e.g. --config=server.cfg (options in server.cfg) +# +# TIDEWALL_STATE a writable directory for the engine's own files and the stop file +# (default $XDG_STATE_HOME/tidewall-server, else +# ~/.local/state/tidewall-server) +set -u + +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +state="${TIDEWALL_STATE:-${XDG_STATE_HOME:-$HOME/.local/state}/tidewall-server}" +grace="${TIDEWALL_STOP_SECONDS:-15}" +stop_file="$state/stop" + +mkdir -p "$state/data" "$state/config" "$state/cache" +rm -f "$stop_file" +export XDG_DATA_HOME="$state/data" XDG_CONFIG_HOME="$state/config" XDG_CACHE_HOME="$state/cache" + +"$here/tidewall.x86_64" --headless -- --server --stop-file="$stop_file" "$@" & +child=$! + +request_stop() { + touch "$stop_file" + ( sleep "$grace"; kill -KILL "$child" 2>/dev/null ) & +} +trap request_stop TERM INT + +wait "$child" +code=$? +while kill -0 "$child" 2>/dev/null; do + wait "$child" + code=$? +done +exit "$code" diff --git a/project.godot b/project.godot index 495dbab..cc80734 100644 --- a/project.godot +++ b/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="Tidewall" +config/version="0.9.0" config/description="A free and open-source build-and-survive battle royale for Linux." run/main_scene="res://src/app/main.tscn" config/features=PackedStringArray("4.7") diff --git a/src/app/build_info.gd b/src/app/build_info.gd new file mode 100644 index 0000000..ee91b68 --- /dev/null +++ b/src/app/build_info.gd @@ -0,0 +1,65 @@ +## R1: which build this is. The version is project.godot's application/config/version. +## The commit is the one `make dist` wrote into build_commit.txt when it exported the +## game. Run from the repository, it is read from .git instead, and "unknown" if +## neither can be found. +class_name BuildInfo +extends RefCounted + +const COMMIT_FILE: String = "res://build_commit.txt" + +static var _commit: String = "" + + +static func version() -> String: + return String(ProjectSettings.get_setting("application/config/version", "0.0.0")) + + +static func commit() -> String: + if _commit.is_empty(): + _commit = _read_commit() + return _commit + + +## "0.9.0 (1a2b3c4d5e6f)", for the main menu and logs. +static func describe() -> String: + return "%s (%s)" % [version(), commit()] + + +static func _read_commit() -> String: + if FileAccess.file_exists(COMMIT_FILE): + var written: String = FileAccess.get_file_as_string(COMMIT_FILE).strip_edges() + if is_valid_commit(written): + return written + var from_git: String = _git_head(ProjectSettings.globalize_path("res://").path_join(".git")) + return from_git if not from_git.is_empty() else "unknown" + + +## A short or full hex commit name, optionally marked "-dirty". +static func is_valid_commit(text: String) -> bool: + var name: String = text.trim_suffix("-dirty") + if name.length() < 7 or name.length() > 40: + return false + for character: String in name: + if not "0123456789abcdef".contains(character): + return false + return true + + +## The commit HEAD names in a .git directory, shortened to 12 characters, or "". +static func _git_head(git_dir: String) -> String: + var head_path: String = git_dir.path_join("HEAD") + if not FileAccess.file_exists(head_path): + return "" + var head: String = FileAccess.get_file_as_string(head_path).strip_edges() + var full: String = head + if head.begins_with("ref: "): + var ref: String = head.trim_prefix("ref: ") + var loose: String = git_dir.path_join(ref) + full = "" + if FileAccess.file_exists(loose): + full = FileAccess.get_file_as_string(loose).strip_edges() + elif FileAccess.file_exists(git_dir.path_join("packed-refs")): + for line: String in FileAccess.get_file_as_string(git_dir.path_join("packed-refs")).split("\n", false): + if line.ends_with(" " + ref): + full = line.get_slice(" ", 0) + return full.substr(0, 12) if is_valid_commit(full) else "" diff --git a/src/app/build_info.gd.uid b/src/app/build_info.gd.uid new file mode 100644 index 0000000..e4f130a --- /dev/null +++ b/src/app/build_info.gd.uid @@ -0,0 +1 @@ +uid://brutau3owyp2q diff --git a/src/server/headless_server.gd b/src/server/headless_server.gd index 353777b..97bd89d 100644 --- a/src/server/headless_server.gd +++ b/src/server/headless_server.gd @@ -79,6 +79,8 @@ func _ready() -> void: _finish(2) return var started: Dictionary = config.to_dictionary() + started["version"] = BuildInfo.version() + started["commit"] = BuildInfo.commit() started["engine"] = Engine.get_version_info()["string"] started["tick_rate_hz"] = Tuning.TICK_RATE_HZ started["world_hash"] = loop.sim.island.heightmap_hash() diff --git a/src/ui/menus.gd b/src/ui/menus.gd index b43aa82..ac41f1a 100644 --- a/src/ui/menus.gd +++ b/src/ui/menus.gd @@ -328,6 +328,13 @@ func _build_main() -> void: _button(column, "Join a server", func() -> void: show_screen("join")) _button(column, "Settings", func() -> void: show_screen("settings")) _button(column, "Quit", func() -> void: quit_requested.emit()) + var build: Label = Label.new() + build.name = "Build" + build.text = "Version " + BuildInfo.describe() + build.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + build.add_theme_font_size_override("font_size", FONT_SMALL) + build.modulate.a = 0.7 + column.add_child(build) func _build_practice() -> void: diff --git a/test/project/test_build_info.gd b/test/project/test_build_info.gd new file mode 100644 index 0000000..540fcb1 --- /dev/null +++ b/test/project/test_build_info.gd @@ -0,0 +1,46 @@ +## R1: the version and commit shown in the main menu and server logs. +extends TestCase + + +func test_version_comes_from_the_project() -> void: + assert_eq(BuildInfo.version(), String(ProjectSettings.get_setting("application/config/version"))) + var parts: PackedStringArray = BuildInfo.version().split(".") + assert_eq(parts.size(), 3, "a three-part version: %s" % BuildInfo.version()) + for part: String in parts: + assert_true(part.is_valid_int(), "%s is a number" % part) + + +func test_commit_is_read_from_the_repository() -> void: + # Tests run from the checkout, which has a .git directory. + var commit: String = BuildInfo.commit() + assert_true(BuildInfo.is_valid_commit(commit), "a commit name: %s" % commit) + assert_true(BuildInfo.describe().begins_with(BuildInfo.version() + " (")) + + +func test_commit_names_are_checked() -> void: + assert_true(BuildInfo.is_valid_commit("0e6e12c")) + assert_true(BuildInfo.is_valid_commit("0e6e12cabc12-dirty")) + assert_false(BuildInfo.is_valid_commit("main")) + assert_false(BuildInfo.is_valid_commit("0e6e")) + assert_false(BuildInfo.is_valid_commit("