-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
1327 lines (1148 loc) · 58.4 KB
/
Justfile
File metadata and controls
1327 lines (1148 loc) · 58.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
#
# RSR Standard Justfile Template
# https://just.systems/man/en/
#
# Copy this file to new projects and customize the placeholder values.
#
# Run `just` to see all available recipes
# Run `just cookbook` to generate docs/just-cookbook.adoc
# Run `just combinations` to see matrix recipe options
set shell := ["bash", "-uc"]
set dotenv-load := true
set positional-arguments := true
# Import auto-generated contractile recipes (must-check, trust-verify, etc.)
# Re-generate with: contractile gen-just
import? "contractile.just"
# Project metadata — customize these
project := "game-server-admin"
version := "0.1.0"
tier := "infrastructure" # 1 | 2 | infrastructure
# ═══════════════════════════════════════════════════════════════════════════════
# DEFAULT & HELP
# ═══════════════════════════════════════════════════════════════════════════════
# Show all available recipes with descriptions
default:
@just --list --unsorted
# Show detailed help for a specific recipe
help recipe="":
#!/usr/bin/env bash
if [ -z "{{recipe}}" ]; then
just --list --unsorted
echo ""
echo "Usage: just help <recipe>"
echo " just cookbook # Generate full documentation"
echo " just combinations # Show matrix recipes"
else
just --show "{{recipe}}" 2>/dev/null || echo "Recipe '{{recipe}}' not found"
fi
# Show this project's info
info:
@echo "Project: game-server-admin"
@echo "Version: {{version}}"
@echo "RSR Tier: {{tier}}"
@echo "Recipes: $(just --summary | wc -w)"
@[ -f ".machine_readable/STATE.a2ml" ] && grep -oP 'phase\s*=\s*"\K[^"]+' .machine_readable/STATE.a2ml | head -1 | xargs -I{} echo "Phase: {}" || true
# ═══════════════════════════════════════════════════════════════════════════════
# INIT — Bootstrap a new project from this template
# ═══════════════════════════════════════════════════════════════════════════════
# Interactive project bootstrap — replaces all {{PLACEHOLDER}} tokens
init:
#!/usr/bin/env bash
set -euo pipefail
echo "═══════════════════════════════════════════════════"
echo " RSR Project Bootstrap"
echo "═══════════════════════════════════════════════════"
echo ""
# --- Load defaults from config (if exists) ---
# Create yours: ~/.config/rsr/defaults
# Format: OWNER=myorg AUTHOR="My Name" AUTHOR_EMAIL=me@example.org ...
DEFAULTS="${XDG_CONFIG_HOME:-$HOME/.config}/rsr/defaults"
if [ -f "$DEFAULTS" ]; then
echo "Loading defaults from $DEFAULTS"
# shellcheck source=/dev/null
source "$DEFAULTS"
echo ""
fi
# --- Required values (pre-filled from defaults if available) ---
read -rp "Project name (human-readable, e.g. My Project): " PROJECT_NAME
[ -z "$PROJECT_NAME" ] && echo "Error: project name required" && exit 1
read -rp "Repository slug (e.g. my-project): " REPO
[ -z "$REPO" ] && echo "Error: repo slug required" && exit 1
read -rp "Owner [${OWNER:-}]: " _OWNER
OWNER="${_OWNER:-${OWNER:-}}"
[ -z "$OWNER" ] && echo "Error: owner required" && exit 1
read -rp "Author full name [${AUTHOR:-}]: " _AUTHOR
AUTHOR="${_AUTHOR:-${AUTHOR:-}}"
[ -z "$AUTHOR" ] && echo "Error: author name required" && exit 1
read -rp "Author email [${AUTHOR_EMAIL:-}]: " _AUTHOR_EMAIL
AUTHOR_EMAIL="${_AUTHOR_EMAIL:-${AUTHOR_EMAIL:-}}"
[ -z "$AUTHOR_EMAIL" ] && echo "Error: email required" && exit 1
# --- Optional values (pre-filled from defaults if available) ---
read -rp "Author organization [${AUTHOR_ORG:-none}]: " _AUTHOR_ORG
AUTHOR_ORG="${_AUTHOR_ORG:-${AUTHOR_ORG:-}}"
read -rp "Previous/alt email [${AUTHOR_EMAIL_ALT:-none}]: " _AUTHOR_EMAIL_ALT
AUTHOR_EMAIL_ALT="${_AUTHOR_EMAIL_ALT:-${AUTHOR_EMAIL_ALT:-}}"
read -rp "Project description []: " PROJECT_DESCRIPTION
read -rp "Forge domain [${FORGE:-github.com}]: " _FORGE
FORGE="${_FORGE:-${FORGE:-github.com}}"
read -rp "Security contact email [${SECURITY_EMAIL:-$AUTHOR_EMAIL}]: " _SECURITY_EMAIL
SECURITY_EMAIL="${_SECURITY_EMAIL:-${SECURITY_EMAIL:-$AUTHOR_EMAIL}}"
read -rp "Conduct contact email [${CONDUCT_EMAIL:-$AUTHOR_EMAIL}]: " _CONDUCT_EMAIL
CONDUCT_EMAIL="${_CONDUCT_EMAIL:-${CONDUCT_EMAIL:-$AUTHOR_EMAIL}}"
read -rp "Project type (library|binary|monorepo|service|website) [library]: " PROJECT_TYPE
PROJECT_TYPE="${PROJECT_TYPE:-library}"
read -rp "Website URL [https://${FORGE}/${OWNER}/${REPO}]: " WEBSITE
WEBSITE="${WEBSITE:-https://${FORGE}/${OWNER}/${REPO}}"
# --- Container values (optional — only relevant if container/ exists) ---
if [ -d "container" ]; then
echo ""
echo "── Container configuration (optional) ─────────"
read -rp "Service name [${REPO}]: " _SERVICE_NAME
SERVICE_NAME="${_SERVICE_NAME:-${REPO}}"
read -rp "Primary port [8080]: " _PORT
PORT="${_PORT:-8080}"
read -rp "Container registry [ghcr.io/${OWNER}]: " _REGISTRY
REGISTRY="${_REGISTRY:-ghcr.io/${OWNER}}"
else
SERVICE_NAME="${REPO}"
PORT="8080"
REGISTRY="ghcr.io/${OWNER}"
fi
# --- Derived values ---
PROJECT_UPPER=$(echo "$REPO" | tr '[:lower:]-' '[:upper:]_')
PROJECT_LOWER=$(echo "$REPO" | tr '[:upper:]-' '[:lower:]_')
CURRENT_YEAR=$(date +%Y)
CURRENT_DATE=$(date +%Y-%m-%d)
VERSION="0.1.0"
# Derive citation name parts (best-effort split on last space)
AUTHOR_LAST="${AUTHOR##* }"
AUTHOR_FIRST="${AUTHOR% *}"
FIRST_INITIAL="${AUTHOR_FIRST:0:1}."
if [ "$AUTHOR_LAST" = "$AUTHOR_FIRST" ]; then
AUTHOR_FIRST="$AUTHOR"
AUTHOR_LAST=""
FIRST_INITIAL=""
fi
echo ""
echo "── Summary ──────────────────────────────────────"
echo " Project: $PROJECT_NAME"
echo " Repo: $REPO"
echo " Owner: $OWNER"
echo " Author: $AUTHOR <$AUTHOR_EMAIL>"
[ -n "$AUTHOR_ORG" ] && echo " Organization: $AUTHOR_ORG"
echo " Forge: $FORGE"
echo " Year: $CURRENT_YEAR"
echo "────────────────────────────────────────────────"
echo ""
read -rp "Proceed? [Y/n] " CONFIRM
[[ "${CONFIRM:-Y}" =~ ^[Nn] ]] && echo "Aborted." && exit 0
echo ""
echo "Replacing placeholders..."
# Brace tokens as variables (hex avoids just interpolation)
LB=$(printf '\x7b\x7b')
RB=$(printf '\x7d\x7d')
# Build the sed expression list
# Note: using | as delimiter since URLs contain /
SED_ARGS=(
-e "s|${LB}PROJECT_NAME${RB}|${PROJECT_NAME}|g"
-e "s|${LB}PROJECT_DESCRIPTION${RB}|${PROJECT_DESCRIPTION}|g"
-e "s|${LB}PROJECT${RB}|${PROJECT_UPPER}|g"
-e "s|${LB}project${RB}|${PROJECT_LOWER}|g"
-e "s|${LB}REPO${RB}|${REPO}|g"
-e "s|${LB}OWNER${RB}|${OWNER}|g"
-e "s|${LB}AUTHOR${RB}|${AUTHOR}|g"
-e "s|${LB}AUTHOR_EMAIL${RB}|${AUTHOR_EMAIL}|g"
-e "s|${LB}AUTHOR_ORG${RB}|${AUTHOR_ORG}|g"
-e "s|${LB}AUTHOR_LAST${RB}|${AUTHOR_LAST}|g"
-e "s|${LB}AUTHOR_FIRST${RB}|${AUTHOR_FIRST}|g"
-e "s|${LB}AUTHOR_INITIALS${RB}|${FIRST_INITIAL}|g"
-e "s|${LB}FORGE${RB}|${FORGE}|g"
-e "s|${LB}CURRENT_YEAR${RB}|${CURRENT_YEAR}|g"
-e "s|${LB}CURRENT_DATE${RB}|${CURRENT_DATE}|g"
-e "s|${LB}DATE${RB}|${CURRENT_DATE}|g"
-e "s|${LB}SECURITY_EMAIL${RB}|${SECURITY_EMAIL}|g"
-e "s|${LB}CONDUCT_EMAIL${RB}|${CONDUCT_EMAIL}|g"
-e "s|${LB}LICENSE${RB}|AGPL-3.0-or-later|g"
-e "s|${LB}CONDUCT_TEAM${RB}|Code of Conduct Committee|g"
-e "s|${LB}RESPONSE_TIME${RB}|48 hours|g"
-e "s|${LB}MAIN_BRANCH${RB}|main|g"
-e "s|${LB}PROJECT_PURPOSE${RB}|${PROJECT_DESCRIPTION}|g"
-e "s|${LB}PROJECT_ROLE${RB}|${PROJECT_TYPE}|g"
-e "s|${LB}PROJECT_TYPE${RB}|${PROJECT_TYPE}|g"
-e "s|${LB}WEBSITE${RB}|${WEBSITE}|g"
-e "s|${LB}SERVICE_NAME${RB}|${SERVICE_NAME}|g"
-e "s|${LB}PORT${RB}|${PORT}|g"
-e "s|${LB}REGISTRY${RB}|${REGISTRY}|g"
-e "s|${LB}IMAGE${RB}|${REGISTRY}/${SERVICE_NAME}|g"
-e "s|${LB}VERSION${RB}|${VERSION}|g"
-e "s|${LB}EMAIL${RB}|${AUTHOR_EMAIL}|g"
)
[ -n "$AUTHOR_EMAIL_ALT" ] && SED_ARGS+=(-e "s|${LB}AUTHOR_EMAIL_ALT${RB}|${AUTHOR_EMAIL_ALT}|g")
# Replace in all text files (skip .git, LICENSE text, and binaries)
find . -type f \
-not -path './.git/*' \
-not -name 'AGPL-3.0-or-later.txt' \
-not -name '*.png' -not -name '*.jpg' -not -name '*.gif' \
-not -name '*.woff' -not -name '*.woff2' \
| while read -r file; do
if file --brief "$file" | grep -qi 'text\|ascii\|utf'; then
sed -i "${SED_ARGS[@]}" "$file"
fi
done
# Also replace game-server-admin and hyperpolymath in AI manifest
sed -i "s|\[YOUR-REPO-NAME\]|${PROJECT_NAME}|g" 0-AI-MANIFEST.a2ml 2>/dev/null || true
sed -i "s|\[YOUR-NAME/ORG\]|${OWNER}|g" 0-AI-MANIFEST.a2ml 2>/dev/null || true
echo ""
echo "── Validation ───────────────────────────────────"
# Check for remaining placeholders
PATTERN="${LB}[A-Z_]*${RB}"
REMAINING=$(grep -rl "$PATTERN" . --include='*.md' --include='*.adoc' --include='*.yml' --include='*.yaml' --include='*.a2ml' --include='*.toml' --include='*.scm' --include='*.ncl' --include='*.nix' --include='*.json' --include='*.sh' 2>/dev/null | grep -v '.git/' | grep -v '.machine_readable/ai/PLACEHOLDERS.adoc' || true)
if [ -n "$REMAINING" ]; then
echo "WARNING: Remaining placeholders in:"
echo "$REMAINING" | sed 's/^/ /'
echo ""
echo "Run: grep -rn '$LB' . --include='*.md' to inspect"
else
echo "All placeholders replaced successfully!"
fi
# K9-SVC validation (if available)
if command -v k9-svc >/dev/null 2>&1; then
echo ""
echo "Running k9-svc validation..."
k9-svc validate . 2>/dev/null || true
fi
echo ""
echo "Done! Next steps:"
echo " 1. Review changes: git diff"
echo " 2. Remove template cruft: rm .machine_readable/ai/PLACEHOLDERS.adoc"
echo " 3. Customize README.adoc for your project"
echo " 4. Commit: git add -A && git commit -m 'feat: initialize from RSR template'"
echo " 5. Push: git remote add origin git@${FORGE}:${OWNER}/${REPO}.git && git push -u origin main"
# ═══════════════════════════════════════════════════════════════════════════════
# BUILD & COMPILE
# ═══════════════════════════════════════════════════════════════════════════════
# Build all layers (ABI + FFI + GUI)
build: build-abi build-ffi build-gui
@echo "Build complete — all layers compiled"
# Build the Idris2 ABI layer (formal type specs)
build-abi:
@echo "Type-checking Idris2 ABI..."
cd src/interface/abi && idris2 --check Types.idr && idris2 --check Foreign.idr && idris2 --check Layout.idr
@echo "ABI type-check passed"
# Build the Zig FFI layer (compile libgsa.so)
build-ffi *args:
@echo "Building Zig FFI (libgsa.so)..."
cd src/interface/ffi && zig build {{args}}
@echo "FFI build complete"
# Build the Ephapax GUI layer
build-gui:
@echo "Compiling Ephapax core logic..."
# Ephapax compiles to Zig via __ffi — the GUI is loaded as HTML at runtime
@echo "GUI build complete (HTML panels loaded at runtime)"
# Build in release mode with optimizations
build-release: build-abi
@echo "Building Zig FFI (release)..."
cd src/interface/ffi && zig build -Doptimize=ReleaseFast
@echo "Release build complete"
# Watch for changes and rebuild FFI
build-watch:
find src/interface/ffi/src -name '*.zig' | entr -c just build-ffi
# Clean build artifacts [reversible: rebuild with `just build`]
clean:
@echo "Cleaning..."
rm -rf src/interface/ffi/zig-out/ src/interface/ffi/zig-cache/
rm -rf src/interface/generated/abi/*.h
# Deep clean including caches [reversible: rebuild]
clean-all: clean
rm -rf .cache .tmp
# ═══════════════════════════════════════════════════════════════════════════════
# GSA-SPECIFIC RECIPES
# ═══════════════════════════════════════════════════════════════════════════════
# Probe a game server by host and port
probe host port="27015":
@echo "Probing {{host}}:{{port}}..."
# Uses the compiled FFI probe engine
cd src/interface/ffi && zig build run -- --probe {{host}} {{port}}
# Scaffold a new game profile A2ML file
add-profile name:
@echo "Creating profiles/{{name}}.a2ml..."
cp profiles/valheim.a2ml profiles/{{name}}.a2ml
sed -i 's/valheim/{{name}}/g; s/Valheim/{{name}}/g' profiles/{{name}}.a2ml
@echo "Profile scaffolded — edit profiles/{{name}}.a2ml to customize"
# Regenerate panel clade definitions from game profiles
generate-clades:
@echo "Generating panel clades from profiles/*.a2ml..."
@bash scripts/generate-clades.sh
@echo "Generated $(ls -d panel-clades/gsa-game-*/ 2>/dev/null | wc -l) game profile clades"
# Start the dedicated VeriSimDB instance
verisimdb-up:
@echo "Starting gsa-verisimdb on port 8090..."
cd container && podman compose -f selur-compose.toml up -d gsa-verisimdb
@echo "VeriSimDB running at http://localhost:8090"
# Stop the dedicated VeriSimDB instance
verisimdb-down:
@echo "Stopping gsa-verisimdb..."
cd container && podman compose -f selur-compose.toml down gsa-verisimdb
# Build the VeriSimDB container image from source
verisimdb-build:
#!/usr/bin/env bash
set -euo pipefail
VERISIMDB_SRC="${VERISIMDB_SRC:-../nextgen-databases/verisimdb}"
if [ ! -d "$VERISIMDB_SRC/rust-core" ]; then
echo "ERROR: VeriSimDB source not found at $VERISIMDB_SRC"
echo "Set VERISIMDB_SRC to the verisimdb repo root"
exit 1
fi
echo "Building gsa-verisimdb image from $VERISIMDB_SRC..."
# Create temp build context with VeriSimDB source
BUILD_CTX=$(mktemp -d)
trap 'rm -rf "$BUILD_CTX"' EXIT
cp container/verisimdb/Containerfile "$BUILD_CTX/"
cp -a "$VERISIMDB_SRC" "$BUILD_CTX/verisimdb-src"
podman build -t gsa-verisimdb:latest -f "$BUILD_CTX/Containerfile" "$BUILD_CTX"
echo "Built gsa-verisimdb:latest"
# Install Podman Quadlet units for VeriSimDB systemd integration
quadlet-install:
#!/usr/bin/env bash
set -euo pipefail
QUADLET_DIR="${HOME}/.config/containers/systemd"
echo "Installing GSA quadlets to $QUADLET_DIR..."
mkdir -p "$QUADLET_DIR"
cp container/verisimdb/gsa-verisimdb.container "$QUADLET_DIR/"
cp container/verisimdb-backup/gsa-verisimdb-backup.container "$QUADLET_DIR/"
systemctl --user daemon-reload
echo "Quadlets installed. Start with:"
echo " systemctl --user start gsa-verisimdb"
echo " systemctl --user start gsa-verisimdb-backup"
# Remove Podman Quadlet units
quadlet-remove:
#!/usr/bin/env bash
set -euo pipefail
QUADLET_DIR="${HOME}/.config/containers/systemd"
echo "Stopping GSA services..."
systemctl --user stop gsa-verisimdb-backup 2>/dev/null || true
systemctl --user stop gsa-verisimdb 2>/dev/null || true
echo "Removing quadlet files..."
rm -f "$QUADLET_DIR/gsa-verisimdb.container"
rm -f "$QUADLET_DIR/gsa-verisimdb-backup.container"
systemctl --user daemon-reload
echo "Quadlets removed."
# Full VeriSimDB deployment: build image → install quadlets → start
verisimdb-deploy:
#!/usr/bin/env bash
set -euo pipefail
echo "═══════════════════════════════════════════════════"
echo " GSA VeriSimDB Deployment Pipeline"
echo "═══════════════════════════════════════════════════"
just verisimdb-build
just quadlet-install
echo ""
echo "Starting VeriSimDB services..."
systemctl --user start gsa-verisimdb
# Wait for main instance health before starting backup
echo "Waiting for main instance health..."
for i in $(seq 1 10); do
if curl -sf http://[::1]:8090/health >/dev/null 2>&1; then
echo " Main instance healthy!"
break
fi
[ "$i" -eq 10 ] && echo "WARNING: Main instance not healthy after 10s"
sleep 1
done
systemctl --user start gsa-verisimdb-backup
echo ""
echo "Deployment complete:"
systemctl --user status gsa-verisimdb --no-pager 2>/dev/null | head -5 || true
systemctl --user status gsa-verisimdb-backup --no-pager 2>/dev/null | head -5 || true
# ─── Game server provisioner ──────────────────────────────────────────────────
#
# Schema-driven game server minter. Reads profiles/<game>.a2ml and
# container/<game>/ to provision a complete running server:
# build → volumes → firewall → quadlet → start → verify → register in VeriSimDB
#
# Usage:
# just game-deploy GAME=cryofall # any supported profile
# just cryofall-deploy # CryoFall shorthand
# just game-deploy GAME=cryofall DRY=1 # preview without executing
# just verpex-deploy GAME=cryofall # SSH deploy to Verpex VPS
# Generic game server deploy — GAME must be a profile ID (profiles/<GAME>.a2ml)
game-deploy GAME="" DRY="0":
#!/usr/bin/env bash
set -euo pipefail
GAME="{{ GAME }}"
if [ -z "${GAME}" ]; then
echo "Usage: just game-deploy GAME=<profile-id>"
echo "Profiles: $(ls profiles/*.a2ml | sed 's|profiles/||; s|\.a2ml||' | tr '\n' ' ')"
exit 1
fi
PROVISION_DRY_RUN="{{ DRY }}" bash scripts/provision-server.sh "${GAME}"
# ─── Fire-and-forget wizard ───────────────────────────────────────────────────
# Complete end-to-end server provisioning including Steam auth and game download.
# Set environment variables before running:
# STEAM_USER, STEAM_PASS, GSA_STEAM_API_KEY (optional, for ID resolution)
# WIZARD_TARGET_HOST (optional, for remote Verpex deployment)
# Interactive wizard — prompts for all values
wizard GAME="cryofall":
bash scripts/wizard.sh --game {{ GAME }}
# Unattended wizard — reads all values from environment
wizard-auto GAME="cryofall":
WIZARD_GAME="{{ GAME }}" bash scripts/wizard.sh --game {{ GAME }} --unattended
# Stage game files from Steam onto the deployment host
# Requires: STEAM_USER, STEAM_PASS
cryofall-stage:
bash scripts/steam-stage.sh \
--app-id 1200170 \
--target-volume cryofall-game-data
# Stage game files to Verpex VPS (set WIZARD_TARGET_HOST or uses default)
cryofall-stage-verpex:
bash scripts/steam-stage.sh \
--app-id 1200170 \
--target-volume cryofall-game-data \
--target-host root@209.42.26.106
# Resolve a Steam vanity URL to a Steam64 ID
# Usage: just steam-resolve VANITY=hyperpolymath API_KEY=<your-key>
steam-resolve VANITY="" API_KEY="":
#!/usr/bin/env bash
set -euo pipefail
VANITY="{{ VANITY }}"
KEY="{{ API_KEY }}"
[ -z "${KEY}" ] && KEY="${GSA_STEAM_API_KEY:-}"
if [ -z "${VANITY}" ]; then
echo "Usage: just steam-resolve VANITY=<username>"
exit 1
fi
GSA_STEAM_API_KEY="${KEY}" src/interface/ffi/zig-out/bin/gsa steam resolve "${VANITY}"
# CryoFall shorthand — equivalent to: just game-deploy GAME=cryofall
cryofall-deploy:
just game-deploy GAME=cryofall
# Build the CryoFall container image only (no full provision)
cryofall-build:
#!/usr/bin/env bash
set -euo pipefail
echo "Building CryoFall server image..."
podman build \
-t localhost/cryofall-server:latest \
-f container/cryofall/Containerfile \
.
echo "Built localhost/cryofall-server:latest"
# CryoFall service management (via systemd Quadlet)
cryofall-start:
systemctl --user start gsa-cryofall
cryofall-stop:
systemctl --user stop gsa-cryofall
cryofall-restart:
systemctl --user restart gsa-cryofall
cryofall-logs:
podman logs --tail 100 -f cryofall
cryofall-status:
#!/usr/bin/env bash
echo "CryoFall container:"
podman inspect --format " Status: {{{{.State.Status}}}} Health: {{{{.State.Health.Status}}}}" cryofall 2>/dev/null || echo " Not running"
echo ""
echo "Systemd service:"
systemctl --user status gsa-cryofall --no-pager 2>/dev/null | head -8 || echo " Not installed"
# Start self-healing watchdog in the foreground
cryofall-watchdog:
bash scripts/self-heal.sh --container cryofall --port 6000
# Install watchdog as a systemd user service (runs in background on Verpex)
cryofall-watchdog-install:
#!/usr/bin/env bash
set -euo pipefail
UNIT_FILE="${HOME}/.config/systemd/user/gsa-cryofall-watchdog.service"
mkdir -p "$(dirname "${UNIT_FILE}")"
REPO="$(pwd)"
cat > "${UNIT_FILE}" << UNIT
[Unit]
Description=GSA CryoFall self-heal watchdog
After=gsa-cryofall.service
Requires=gsa-cryofall.service
[Service]
Type=simple
ExecStart=/usr/bin/bash ${REPO}/scripts/self-heal.sh --container cryofall --port 6000
Restart=always
RestartSec=10s
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=default.target
UNIT
systemctl --user daemon-reload
systemctl --user enable --now gsa-cryofall-watchdog
echo "Watchdog service installed and started."
systemctl --user status gsa-cryofall-watchdog --no-pager | head -6
# Deploy to Verpex VPS via SSH (run this from local machine)
# Requires SSH key access: root@209.42.26.106
verpex-deploy GAME="cryofall":
#!/usr/bin/env bash
set -euo pipefail
GAME="{{ GAME }}"
VERPEX_HOST="209.42.26.106"
VERPEX_USER="root"
echo "Deploying ${GAME} server to Verpex VPS (${VERPEX_HOST})..."
# Copy provisioner + profiles + container definition
ssh "${VERPEX_USER}@${VERPEX_HOST}" "mkdir -p ~/gsa-provision/${GAME}"
rsync -az --progress \
profiles/ scripts/ container/"${GAME}"/ \
"${VERPEX_USER}@${VERPEX_HOST}:~/gsa-provision/${GAME}/"
# Run provisioner on the VPS
ssh "${VERPEX_USER}@${VERPEX_HOST}" "cd ~/gsa-provision/${GAME} && bash provision-server.sh ${GAME}"
echo "Remote provisioning complete."
# Check VeriSimDB systemd service status
verisimdb-status:
#!/usr/bin/env bash
echo "Main VeriSimDB (port 8090):"
systemctl --user status gsa-verisimdb --no-pager 2>/dev/null || echo " Not installed"
echo ""
echo "Backup VeriSimDB (port 8091):"
systemctl --user status gsa-verisimdb-backup --no-pager 2>/dev/null || echo " Not installed"
echo ""
echo "Health checks:"
curl -sf http://[::1]:8090/health && echo " ← main (8090)" || echo " main (8090): unreachable"
curl -sf http://[::1]:8091/health && echo " ← backup (8091)" || echo " backup (8091): unreachable"
# Launch the Gossamer GUI
gui: build-ffi
@echo "Launching Game Server Admin..."
GSA_VERISIMDB_URL="${GSA_VERISIMDB_URL:-http://localhost:8090}" \
GSA_PROFILES_DIR="${GSA_PROFILES_DIR:-./profiles}" \
./src/interface/ffi/zig-out/bin/gsa status
# Test probe engine against known ports
test-probe:
@echo "Testing probe engine..."
cd src/interface/ffi && zig build test -- --filter "probe"
# Test A2ML round-trip (extract → serialise → deserialise)
test-a2ml:
@echo "Testing A2ML round-trip..."
cd src/interface/ffi && zig build test -- --filter "a2ml"
# Test VeriSimDB CRUD and drift detection
test-verisimdb:
@echo "Testing VeriSimDB client..."
cd src/interface/ffi && zig build test -- --filter "verisimdb"
# Count game profiles loaded
profile-count:
@echo "Game profiles: $(ls profiles/*.a2ml 2>/dev/null | wc -l)"
@echo "Panel clades: $(ls -d panel-clades/gsa-game-*/ 2>/dev/null | wc -l)"
# ═══════════════════════════════════════════════════════════════════════════════
# TEST & QUALITY
# ═══════════════════════════════════════════════════════════════════════════════
# Run all tests (unit + integration)
test *args:
@echo "Running Zig unit tests..."
cd src/interface/ffi && zig build test {{args}}
@echo "Running Zig integration tests..."
cd src/interface/ffi && zig build test-integration {{args}}
@echo "All tests passed!"
# Run tests with verbose output
test-verbose:
@echo "Running tests (verbose)..."
cd src/interface/ffi && zig build test 2>&1
# Smoke test — quick sanity: build + unit tests + profile count
test-smoke:
#!/usr/bin/env bash
set -euo pipefail
FFI_DIR="src/interface/ffi"
echo "Smoke test: build FFI..."
(cd "$FFI_DIR" && zig build)
echo "Smoke test: unit tests..."
(cd "$FFI_DIR" && zig build test)
echo "Smoke test: smoke suite..."
(cd "$FFI_DIR" && zig build test-smoke)
PROFILES=$(ls profiles/*.a2ml 2>/dev/null | wc -l)
echo "Smoke test: $PROFILES game profiles found"
[[ "$PROFILES" -ge 1 ]] || { echo "FAIL: No game profiles"; exit 1; }
echo "Smoke test passed!"
# Run all quality checks
quality: fmt-check lint test
@echo "All quality checks passed!"
# Fix all auto-fixable issues [reversible: git checkout]
fix: fmt
@echo "Fixed all auto-fixable issues"
# ═══════════════════════════════════════════════════════════════════════════════
# LINT & FORMAT
# ═══════════════════════════════════════════════════════════════════════════════
# Format all source files [reversible: git checkout]
fmt:
@echo "Formatting source files..."
cd src/interface/ffi && zig fmt src/ test/ build.zig 2>/dev/null || true
# Check formatting without changes
fmt-check:
@echo "Checking formatting..."
cd src/interface/ffi && zig fmt --check src/ test/ build.zig 2>/dev/null || true
# Run linter (Zig build acts as a type checker / linter)
lint:
@echo "Linting source files..."
cd src/interface/ffi && zig build 2>&1 | head -50 || true
# ═══════════════════════════════════════════════════════════════════════════════
# RUN & EXECUTE
# ═══════════════════════════════════════════════════════════════════════════════
# Launch GSA (platform-detect, self-heal, git cycle)
run:
deno run --allow-all run.js
# Run the GSA binary directly (status probe, config, etc.)
run-admin *args: build-ffi
GSA_VERISIMDB_URL="${GSA_VERISIMDB_URL:-http://localhost:8090}" \
GSA_PROFILES_DIR="${GSA_PROFILES_DIR:-./profiles}" \
./src/interface/ffi/zig-out/bin/gsa {{args}}
# Run with verbose output
run-verbose *args: build-ffi
GSA_VERISIMDB_URL="${GSA_VERISIMDB_URL:-http://localhost:8090}" \
GSA_PROFILES_DIR="${GSA_PROFILES_DIR:-./profiles}" \
./src/interface/ffi/zig-out/bin/gsa {{args}}
# Install to user path
install: build-release
@echo "Installing game-server-admin..."
install -Dm755 src/interface/ffi/zig-out/bin/gsa "$HOME/.local/bin/gsa"
@echo "Installed gsa to ~/.local/bin/gsa"
# ═══════════════════════════════════════════════════════════════════════════════
# DEPENDENCIES
# ═══════════════════════════════════════════════════════════════════════════════
# Install/check all dependencies (Zig has no external deps)
deps:
@echo "Checking dependencies..."
@command -v zig >/dev/null && echo " zig: $(zig version)" || echo " zig: NOT FOUND"
@command -v idris2 >/dev/null && echo " idris2: $(idris2 --version 2>/dev/null | head -1)" || echo " idris2: NOT FOUND (optional, for ABI proofs)"
@echo "All dependencies satisfied"
# Audit dependencies for vulnerabilities
deps-audit:
@echo "Auditing for vulnerabilities..."
@command -v trivy >/dev/null && trivy fs --severity HIGH,CRITICAL --quiet . || true
@command -v gitleaks >/dev/null && gitleaks detect --source . --no-git --quiet || true
@echo "Audit complete"
# ═══════════════════════════════════════════════════════════════════════════════
# DOCUMENTATION
# ═══════════════════════════════════════════════════════════════════════════════
# Generate all documentation
docs:
@mkdir -p docs/generated docs/man
just cookbook
just man
@echo "Documentation generated in docs/"
# Generate justfile cookbook documentation
cookbook:
#!/usr/bin/env bash
mkdir -p docs
OUTPUT="docs/just-cookbook.adoc"
echo "= game-server-admin Justfile Cookbook" > "$OUTPUT"
echo ":toc: left" >> "$OUTPUT"
echo ":toclevels: 3" >> "$OUTPUT"
echo "" >> "$OUTPUT"
echo "Generated: $(date -Iseconds)" >> "$OUTPUT"
echo "" >> "$OUTPUT"
echo "== Recipes" >> "$OUTPUT"
echo "" >> "$OUTPUT"
just --list --unsorted | while read -r line; do
if [[ "$line" =~ ^[[:space:]]+([a-z_-]+) ]]; then
recipe="${BASH_REMATCH[1]}"
echo "=== $recipe" >> "$OUTPUT"
echo "" >> "$OUTPUT"
echo "[source,bash]" >> "$OUTPUT"
echo "----" >> "$OUTPUT"
echo "just $recipe" >> "$OUTPUT"
echo "----" >> "$OUTPUT"
echo "" >> "$OUTPUT"
fi
done
echo "Generated: $OUTPUT"
# Generate man page
man:
#!/usr/bin/env bash
mkdir -p docs/man
cat > docs/man/game-server-admin.1 << EOF
.TH game-server-admin 1 "$(date +%Y-%m-%d)" "{{version}}" "game-server-admin Manual"
.SH NAME
game-server-admin \- RSR-compliant project
.SH SYNOPSIS
.B just
[recipe] [args...]
.SH DESCRIPTION
RSR (Rhodium Standard Repository) project managed with just.
.SH AUTHOR
$(git config user.name 2>/dev/null || echo "Author") <$(git config user.email 2>/dev/null || echo "email")>
EOF
echo "Generated: docs/man/game-server-admin.1"
# ═══════════════════════════════════════════════════════════════════════════════
# CONTAINERS (stapeln ecosystem — Podman + Chainguard Wolfi)
# ═══════════════════════════════════════════════════════════════════════════════
# Initialise container templates — substitute placeholders with project values
container-init:
#!/usr/bin/env bash
set -euo pipefail
if [ ! -d "container" ]; then
echo "Error: container/ directory not found."
echo "This repo may not have been created from rsr-template-repo."
exit 1
fi
echo "=== Container Template Initialisation ==="
echo ""
# Load RSR defaults if available
DEFAULTS="${XDG_CONFIG_HOME:-$HOME/.config}/rsr/defaults"
if [ -f "$DEFAULTS" ]; then
echo "Loading defaults from $DEFAULTS"
# shellcheck source=/dev/null
source "$DEFAULTS"
echo ""
fi
# Prompt for container-specific values
read -rp "Service name (e.g. my-api) [game-server-admin]: " _SERVICE_NAME
SERVICE_NAME="${_SERVICE_NAME:-game-server-admin}"
read -rp "Primary port [8080]: " _PORT
PORT="${_PORT:-8080}"
read -rp "Container registry [ghcr.io/${OWNER:-hyperpolymath}]: " _REGISTRY
REGISTRY="${_REGISTRY:-ghcr.io/${OWNER:-hyperpolymath}}"
echo ""
echo " Service: $SERVICE_NAME"
echo " Port: $PORT"
echo " Registry: $REGISTRY"
echo ""
read -rp "Proceed? [Y/n] " CONFIRM
[[ "${CONFIRM:-Y}" =~ ^[Nn] ]] && echo "Aborted." && exit 0
echo ""
echo "Replacing container placeholders..."
# Brace tokens as variables (hex escapes avoid just interpolation)
LB=$(printf '\x7b\x7b')
RB=$(printf '\x7d\x7d')
SED_ARGS=(
-e "s|${LB}SERVICE_NAME${RB}|${SERVICE_NAME}|g"
-e "s|${LB}PORT${RB}|${PORT}|g"
-e "s|${LB}REGISTRY${RB}|${REGISTRY}|g"
)
find container/ -type f | while read -r file; do
if file --brief "$file" | grep -qi 'text\|ascii\|utf'; then
sed -i "${SED_ARGS[@]}" "$file"
fi
done
echo "Container templates initialised."
echo ""
echo "Next steps:"
echo " 1. Edit container/Containerfile — add your build commands"
echo " 2. Edit container/entrypoint.sh — set your application binary"
echo " 3. Review container/compose.toml — adjust services and volumes"
echo " 4. Build: just container-build"
# Build container image via cerro-torre pipeline
container-build *args:
#!/usr/bin/env bash
if [ -f "container/ct-build.sh" ]; then
cd container && ./ct-build.sh {{args}}
elif [ -f "container/Containerfile" ]; then
podman build -t game-server-admin:latest -f container/Containerfile .
elif [ -f "Containerfile" ]; then
podman build -t game-server-admin:latest -f Containerfile .
else
echo "No Containerfile found in container/ or project root"
exit 1
fi
# Verify compose configuration
container-verify:
#!/usr/bin/env bash
if [ ! -f "container/compose.toml" ]; then
echo "No container/compose.toml found"
exit 1
fi
cd container
if command -v selur-compose &>/dev/null; then
selur-compose verify
else
echo "selur-compose not found, falling back to podman compose"
podman compose --file compose.toml config
fi
# Start container stack
container-up *args:
#!/usr/bin/env bash
if [ ! -f "container/compose.toml" ]; then
echo "No container/compose.toml found"
exit 1
fi
cd container
if command -v selur-compose &>/dev/null; then
selur-compose up {{args}}
else
podman compose --file compose.toml up {{args}}
fi
# Stop container stack
container-down:
#!/usr/bin/env bash
cd container 2>/dev/null || { echo "No container/ directory"; exit 1; }
if command -v selur-compose &>/dev/null; then
selur-compose down
else
podman compose --file compose.toml down
fi
# Sign and verify container bundle (build + pack + sign + verify)
container-sign:
#!/usr/bin/env bash
if [ -f "container/ct-build.sh" ]; then
cd container && ./ct-build.sh
else
echo "No container/ct-build.sh found"
exit 1
fi
# Push signed bundle to registry
container-push:
#!/usr/bin/env bash
if [ -f "container/ct-build.sh" ]; then
cd container && ./ct-build.sh --push
else
echo "No container/ct-build.sh found — falling back to podman push"
podman push game-server-admin:latest
fi
# Run container interactively (for debugging)
container-run *args:
podman run --rm -it game-server-admin:latest {{args}}
# ═══════════════════════════════════════════════════════════════════════════════
# CI & AUTOMATION
# ═══════════════════════════════════════════════════════════════════════════════
# Run full CI pipeline locally
ci: deps quality
@echo "CI pipeline complete!"
# Install git hooks
install-hooks:
@mkdir -p .git/hooks
@cat > .git/hooks/pre-commit << 'HOOKEOF'
#!/bin/bash
just fmt-check || exit 1
just lint || exit 1
just assail || exit 1
HOOKEOF
@chmod +x .git/hooks/pre-commit
@echo "Git hooks installed"
# ═══════════════════════════════════════════════════════════════════════════════
# SECURITY
# ═══════════════════════════════════════════════════════════════════════════════
# Run security audit
security: deps-audit
@echo "=== Security Audit ==="
@command -v gitleaks >/dev/null && gitleaks detect --source . --verbose || true
@command -v trivy >/dev/null && trivy fs --severity HIGH,CRITICAL . || true
@echo "Security audit complete"
# Generate SBOM
sbom:
@mkdir -p docs/security
@command -v syft >/dev/null && syft . -o spdx-json > docs/security/sbom.spdx.json || echo "syft not found"
# ═══════════════════════════════════════════════════════════════════════════════
# VALIDATION & COMPLIANCE
# ═══════════════════════════════════════════════════════════════════════════════
# Validate RSR compliance
validate-rsr:
#!/usr/bin/env bash
echo "=== RSR Compliance Check ==="
MISSING=""
for f in .editorconfig .gitignore Justfile README.adoc LICENSE 0-AI-MANIFEST.a2ml; do
[ -f "$f" ] || MISSING="$MISSING $f"
done
for f in .machine_readable/STATE.a2ml .machine_readable/META.a2ml .machine_readable/ECOSYSTEM.a2ml .machine_readable/anchors/ANCHOR.a2ml .machine_readable/policies/MAINTENANCE-AXES.a2ml .machine_readable/policies/MAINTENANCE-CHECKLIST.a2ml .machine_readable/policies/SOFTWARE-DEVELOPMENT-APPROACH.a2ml; do
[ -f "$f" ] || MISSING="$MISSING $f"
done
for f in licensing/exhibits/EXHIBIT-A-ETHICAL-USE.txt licensing/exhibits/EXHIBIT-B-QUANTUM-SAFE.txt licensing/texts/AGPL-3.0-or-later.txt; do
[ -f "$f" ] || MISSING="$MISSING $f"
done
for f in src/interface/abi src/interface/ffi src/interface/generated; do
[ -d "$f" ] || MISSING="$MISSING $f"
done
for f in docs/maintenance/MAINTENANCE-CHECKLIST.adoc docs/practice/SOFTWARE-DEVELOPMENT-APPROACH.adoc; do
[ -f "$f" ] || MISSING="$MISSING $f"
done
if [ -f ".machine_readable/META.a2ml" ]; then
grep -q 'axis-1 = "must > intend > like"' .machine_readable/META.a2ml || MISSING="$MISSING META.a2ml:axis-1"
grep -q 'axis-2 = "corrective > adaptive > perfective"' .machine_readable/META.a2ml || MISSING="$MISSING META.a2ml:axis-2"
grep -q 'axis-3 = "systems > compliance > effects"' .machine_readable/META.a2ml || MISSING="$MISSING META.a2ml:axis-3"
grep -q 'scoping-first = true' .machine_readable/META.a2ml || MISSING="$MISSING META.a2ml:scoping-first"
grep -q 'idris-unsound-scan = "believe_me/assert_total"' .machine_readable/META.a2ml || MISSING="$MISSING META.a2ml:idris-unsound-scan"
grep -q 'audit-focus = "systems in place, documentation explains actual state, safety/security accounted for, observed effects reviewed"' .machine_readable/META.a2ml || MISSING="$MISSING META.a2ml:audit-focus"
grep -q 'compliance-focus = "seams/compromises/exception register, bounded exceptions, anti-drift checks"' .machine_readable/META.a2ml || MISSING="$MISSING META.a2ml:compliance-focus"
grep -q 'effects-evidence = "benchmark execution/results and maintainer status dialogue/review"' .machine_readable/META.a2ml || MISSING="$MISSING META.a2ml:effects-evidence"
grep -q 'compliance-tooling = "panic-attack"' .machine_readable/policies/MAINTENANCE-AXES.a2ml || MISSING="$MISSING MAINTENANCE-AXES.a2ml:compliance-tooling"
grep -q 'effects-tooling = "ecological checking with sustainabot guidance"' .machine_readable/policies/MAINTENANCE-AXES.a2ml || MISSING="$MISSING MAINTENANCE-AXES.a2ml:effects-tooling"
grep -q 'source-human = "docs/maintenance/MAINTENANCE-CHECKLIST.adoc"' .machine_readable/policies/MAINTENANCE-CHECKLIST.a2ml || MISSING="$MISSING MAINTENANCE-CHECKLIST.a2ml:source-human"
grep -q 'source-human = "docs/practice/SOFTWARE-DEVELOPMENT-APPROACH.adoc"' .machine_readable/policies/SOFTWARE-DEVELOPMENT-APPROACH.a2ml || MISSING="$MISSING SOFTWARE-DEVELOPMENT-APPROACH.a2ml:source-human"
fi
if [ -n "$MISSING" ]; then
echo "MISSING:$MISSING"
exit 1
fi
echo "RSR compliance: PASS"
# Validate STATE.a2ml syntax
validate-state:
@if [ -f ".machine_readable/STATE.a2ml" ]; then \