Repository-cleanup / DX pass folding three tracker items into one coherent change, verified green end to end (`bin/x test` 49/0, `bin/x selfhost-test` 29/0, `bin/x test-tools` 29/0). #28 — curate & categorise examples/ - 42 flat entries regrouped into intent-revealing subdirs: games/, rendering/, ecs/, events/, networking/, lang/, library/ (was lib/). - chronorift dir-vs-file duplication resolved: the entry file and its import modules now live together under games/chronorift(.ludic). - Every path reference updated repo-wide (test runner, editor-tool drivers, docs/site, design docs). - New examples/README.md indexes the whole set with run commands. - Showcase examples without a self-asserting entry (hello, events, net_rt) now get a compile-only rot guard in `bin/x test`, so nothing here rots silently. #30 — text-diffable golden baseline - The 4 binary selfhost/golden/*.ppm blobs are replaced by a single selfhost/golden/renders.sha256 manifest (SHA-256 per render). Hashes are byte-identical to the old PPMs, so the baseline is unchanged — only its form. - game_case now compares framebuffer hashes; a regression shows as a changed hex line in review, not "binary files differ". - New `bin/x golden` regenerates the manifest deliberately (review with `git diff selfhost/golden/renders.sha256`). #27 — PPM & asset handling - Headless renders now write build/out.ppm, never the repo root; `x app`, `x clean`, messaging and .gitignore updated to match. Nothing is written to the working root any more. - Redundant local Kenney .zip archives removed (the art ships extracted; .gitignore already excludes *.zip). CC0 License.txt files retained. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1.6 KiB
Text
33 lines
1.6 KiB
Text
# net_roles.ludic — N5: handler roles + the drivable sim (NETWORKING-DESIGN §6.2,
|
|
# §5, §13 N5).
|
|
#
|
|
# A handler's network role is a declarative annotation, never a runtime branch in
|
|
# ordinary code:
|
|
# (unmarked) runs on every peer — the shared, deterministic simulation
|
|
# @Server runs only on the authority (clients get the result via @Sync)
|
|
# @Predicted runs on the owning client and the server (auto-reconciled)
|
|
# The runtime sets the peer's role register (set_role); offline it defaults to
|
|
# server, so guards collapse to "run here" and a non-networked build is unchanged.
|
|
#
|
|
# The per-frame phases are also exposed as callables — tick_fixed() runs the sim
|
|
# phases — so this game owns its own loop via `entry` (for prediction/rollback,
|
|
# replay, headless tests). Acting as a client then the server: 1, then 102.
|
|
program NetRoles {
|
|
property Score { n: int = 0 }
|
|
model Board { Score }
|
|
|
|
handler Both phase Update { for (Score) in query [Score] { Score.n = Score.n + 1 } } # runs everywhere
|
|
@Server handler ServerOnly phase Update { for (Score) in query [Score] { Score.n = Score.n + 100 } } # authority only
|
|
|
|
entry {
|
|
spawn Board { Score { n: 0 } }
|
|
|
|
set_role(0) # act as a client
|
|
tick_fixed() # Both(+1); ServerOnly skipped
|
|
for (Score) in query [Score] { print(Score.n) } # 1
|
|
|
|
set_role(1) # act as the server
|
|
tick_fixed() # Both(+1) + ServerOnly(+100)
|
|
for (Score) in query [Score] { print(Score.n) } # 102
|
|
}
|
|
}
|