@wildshard/engine 0.1.22 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/index.html +17 -4
- package/lint/engine-sides.json +9 -0
- package/lint/sim-players.json +2 -13
- package/package.json +36 -3
- package/scripts/apfs-clone.mjs +5 -2
- package/scripts/app-build/catalogue.ts +39 -8
- package/scripts/app-build/serviceWorker.ts +4 -1
- package/scripts/app-build/splitOutput.mjs +33 -11
- package/scripts/app-build/titlePreloads.mjs +8 -5
- package/scripts/bake-road-surfaces.entry.ts +18 -0
- package/scripts/bake-road-surfaces.mjs +44 -0
- package/scripts/changelog.mjs +2 -1
- package/scripts/ci-pack.mjs +3 -3
- package/scripts/engine-ci-shard.mjs +11 -0
- package/scripts/fight-page-census.mjs +131 -0
- package/scripts/goldens/board.py +44 -11
- package/scripts/goldens/capture.mjs +18 -6
- package/scripts/goldens/native-residency.d.mts +2 -0
- package/scripts/goldens/native-residency.mjs +31 -4
- package/scripts/grid-road-lag.mjs +209 -0
- package/scripts/keep-copy.mjs +172 -0
- package/scripts/land.d.mts +4 -1
- package/scripts/land.mjs +121 -9
- package/scripts/lane-live.mjs +136 -0
- package/scripts/leftovers-report.mjs +47 -0
- package/scripts/loading-card-proof.mjs +42 -9
- package/scripts/loading-flow/benchmax.mjs +59 -7
- package/scripts/loading-flow/stalls.d.mts +2 -0
- package/scripts/loading-flow/stalls.mjs +13 -0
- package/scripts/map-hash.mjs +1 -1
- package/scripts/mmo-bots.mjs +5 -3
- package/scripts/mmo-grid-proof.mjs +74 -0
- package/scripts/mmo-seat-proof.mjs +43 -0
- package/scripts/nightly-heads.ts +13 -13
- package/scripts/nightly-model.ts +26 -12
- package/scripts/nightly-tag.mjs +2 -4
- package/scripts/nightly.proof.ts +18 -5
- package/scripts/nightly.ts +13 -8
- package/scripts/no-astc-boot.mjs +77 -0
- package/scripts/page-release/content.mjs +19 -10
- package/scripts/page-release/flow.d.mts +3 -2
- package/scripts/page-release/flow.mjs +31 -21
- package/scripts/page-release/packs.d.mts +5 -0
- package/scripts/page-release/packs.mjs +13 -3
- package/scripts/page-release/preview.d.mts +2 -0
- package/scripts/page-release/preview.mjs +74 -0
- package/scripts/page-release.mjs +13 -5
- package/scripts/physics-route.json +6 -6
- package/scripts/pins-reuse.mjs +1 -0
- package/scripts/pins-staging.ts +54 -0
- package/scripts/pins.ts +5 -0
- package/scripts/ring3.proof.ts +71 -0
- package/scripts/ring3.ts +100 -0
- package/scripts/road-drive-proof.mjs +269 -0
- package/scripts/road-memory-probe.mjs +129 -0
- package/scripts/scratch-dir.mjs +33 -14
- package/scripts/scratch-sweep.mjs +15 -23
- package/scripts/server-release/github.mjs +59 -26
- package/scripts/server-release/items.d.mts +7 -0
- package/scripts/server-release/items.mjs +28 -0
- package/scripts/server-release/publish.mjs +24 -2
- package/scripts/server-release/sign.mjs +8 -4
- package/scripts/side-parity.mjs +1 -1
- package/scripts/test-products.json +1 -0
- package/scripts/test_prebuilt_output.py +3 -1
- package/scripts/tsconfig.json +2 -0
- package/scripts/turn-in-shots.mjs +83 -0
- package/scripts/vitest-bench-observe-proof.py +168 -0
- package/scripts/vitest-bench.py +122 -77
- package/scripts/vitest-ci-files.ts +5 -1
- package/scripts/vps/rebuild.sh +3 -1
- package/scripts/vps/wildshard-config +106 -1
- package/scripts/warm-native-chrome.mjs +9 -3
- package/scripts/worker-client-fights.mjs +9 -3
- package/scripts/worktree-reap.mjs +36 -140
- package/scripts/worktree.mjs +92 -12
- package/scripts/zone-gate-proof.mjs +93 -0
- package/src/client/engine/audio/audioLog.ts +7 -2
- package/src/client/engine/boot/diagnostics.ts +69 -1
- package/src/client/engine/boot/sw.ts +3 -1
- package/src/client/engine/core/ktx2.ts +33 -10
- package/src/client/engine/core/ktx2Zstd.ts +2 -1
- package/src/client/engine/models/place.ts +7 -5
- package/src/client/engine/pwa/sw.js +83 -10
- package/src/client/engine/render/dataLook.ts +14 -7
- package/src/client/engine/render/lookLight.ts +64 -20
- package/src/client/engine/render/precompile.ts +6 -0
- package/src/client/engine/render/tiers.ts +9 -0
- package/src/client/engine/ui/Loading.ts +6 -8
- package/src/client/engine/ui/lookLightOption.ts +1 -1
- package/src/client/engine/ui/playerReload.ts +5 -5
- package/src/client/game/audio/cueDirector.ts +2 -1
- package/src/client/game/boot/bytes.generated.ts +4 -1
- package/src/client/game/boot/versions.generated.ts +8 -5
- package/src/client/game/boss/arenaRoom.ts +4 -3
- package/src/client/game/boss/roamingProjection.ts +1 -1
- package/src/client/game/devScene/hook.ts +1 -1
- package/src/client/game/devScene/liveLook.ts +1 -1
- package/src/client/game/grid/cellClip.ts +70 -6
- package/src/client/game/grid/dataCellKit.ts +9 -1
- package/src/client/game/grid/gateCard.css +9 -0
- package/src/client/game/grid/gateCard.ts +67 -0
- package/src/client/game/grid/live.ts +17 -3
- package/src/client/game/grid/liveSession.ts +15 -5
- package/src/client/game/grid/neighbourLife.ts +10 -1
- package/src/client/game/grid/neighbourPanels.ts +29 -2
- package/src/client/game/grid/pageEntry.ts +21 -0
- package/src/client/game/grid/products.ts +21 -7
- package/src/client/game/grid/regionalWorld.ts +5 -0
- package/src/client/game/grid/roadCompressedSurfaces.ts +69 -0
- package/src/client/game/grid/roadLook.ts +5 -73
- package/src/client/game/grid/roadLookPlatform.ts +11 -6
- package/src/client/game/grid/roadSurfaceMaps.ts +80 -0
- package/src/client/game/grid/roadTilePool.ts +4 -0
- package/src/client/game/grid/session.ts +58 -16
- package/src/client/game/grid/softWallLook.ts +6 -1
- package/src/client/game/plugin/ui.ts +3 -0
- package/src/client/game/population/signals.ts +1 -1
- package/src/client/game/quest/chapterDirector.ts +1 -0
- package/src/client/game/session/play.ts +3 -0
- package/src/client/game/shardfile/clientBossTelegraph.ts +4 -3
- package/src/client/game/shardfile/clientSource.ts +5 -2
- package/src/client/game/shardfile/clientWorker.ts +25 -8
- package/src/client/game/shardfile/look.ts +1 -1
- package/src/client/game/shardfile/runtimeProduct.ts +9 -5
- package/src/client/game/shardfile/slabLibrary.ts +37 -0
- package/src/client/game/shardfile/slabRanges.ts +145 -0
- package/src/client/game/shardfile/wirePage.ts +5 -2
- package/src/client/game/shardfile/worldSceneTextures.ts +15 -9
- package/src/client/host/online/shell.ts +2 -2
- package/src/client/host/standalone/shell.ts +4 -1
- package/src/cook/game/cookWorker.ts +8 -5
- package/src/cook/game/tierTextures.ts +5 -3
- package/src/server/engine/net/simWorld.ts +3 -4
- package/src/server/game/grid/cellHome.ts +58 -0
- package/src/server/game/grid/simulation.ts +32 -8
- package/src/server/game/plugin/mover.ts +18 -14
- package/src/server/game/plugin/simulation.ts +2 -0
- package/src/server/game/shardfile/dataRespawn.ts +47 -0
- package/src/server/game/shardfile/declaredKitItems.ts +31 -7
- package/src/server/host/bake/headlessWorker.ts +3 -3
- package/src/server/host/dedicated/cellWorker.ts +4 -2
- package/src/server/host/dedicated/main.ts +7 -4
- package/src/server/host/dedicated/packReader.ts +15 -2
- package/src/server/host/dedicated/playerStore.ts +1 -1
- package/src/server/host/headlessRuntime.ts +11 -6
- package/src/server/host/standalone/cellWorld.ts +20 -6
- package/src/server/host/standalone/gridServer.ts +20 -6
- package/src/server/host/standalone/roadWorld.ts +36 -0
- package/src/server/host/standalone/serverHost.ts +2 -2
- package/src/shared/engine/entities/AnimalSim.ts +10 -0
- package/src/shared/engine/physics/gridBorders.ts +15 -1
- package/src/shared/engine/physics/transferWalls.ts +9 -4
- package/src/shared/engine/sim/snapshot.ts +5 -5
- package/src/shared/game/grid/allocator.ts +8 -1
- package/src/shared/game/grid/gateCount.ts +27 -0
- package/src/shared/game/grid/zoneWalls.ts +64 -0
- package/src/shared/game/ledger.ts +13 -4
- package/src/shared/game/loot/platformCatalogue.ts +14 -0
- package/src/shared/game/quest/ledger.ts +3 -3
- package/src/shared/game/shardfile/items.ts +9 -1
- package/src/shared/game/strings.ts +2 -0
- package/src/shared/host/headlessJourney.ts +3 -3
- package/src/shared/host/headlessTape.ts +7 -6
- package/src/shared/host/releaseRows.ts +4 -1
- package/src/shared/host/standalone/harnessPlace.ts +4 -0
- package/src/test/engine/simState.ts +134 -0
- package/src/test/game/builtProduct.ts +6 -0
- package/src/test/game/headless/admittedProductCache.ts +61 -0
- package/src/test/game/headless/checkedReplayPipeline.ts +21 -0
- package/src/test/game/headless/nativeBounds.ts +27 -0
- package/src/test/game/headless/processUsage.ts +22 -0
- package/src/test/game/headless/productSession.ts +39 -0
- package/src/test/game/headless/ropeBodies.ts +60 -0
- package/src/test/game/headless/worker.ts +34 -0
- package/src/test/game/headlessNative.ts +114 -0
- package/src/test/game/headlessWorker.ts +43 -0
- package/src/test/tsconfig.game.json +3 -0
package/scripts/vitest-bench.py
CHANGED
|
@@ -9,7 +9,8 @@ macOS and Linux includes every reaped descendant), the largest single-process ma
|
|
|
9
9
|
python3 scripts/vitest-bench.py run [--out tmp/vitest-bench/results.json] [--slots 2] [FILE ...]
|
|
10
10
|
python3 scripts/vitest-bench.py table [--in tmp/vitest-bench/results.json] [--top 30]
|
|
11
11
|
python3 scripts/vitest-bench.py pack [--in ...] [--workers 4,5,6,10]
|
|
12
|
-
python3 scripts/vitest-bench.py observe
|
|
12
|
+
python3 scripts/vitest-bench.py observe --out tmp/YOUR-LANE/census.json [--pid PID | --count 3]
|
|
13
|
+
(passive identity-aware census; sampled CPU lower bounds, not exact full-gate totals)
|
|
13
14
|
|
|
14
15
|
`run` resumes: files already in the results JSON at the same commit are skipped. The bench is the machine's
|
|
15
16
|
lowest-priority caller. It starts a file only while no full-test lease is held or queued, nobody else waits for
|
|
@@ -682,84 +683,114 @@ def command_pack(args):
|
|
|
682
683
|
'packedWallSeconds': {n: round(pack(net, n), 1) for n in args.workers}}, indent=1))
|
|
683
684
|
|
|
684
685
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
parts = [float(part) for part in text.split(':')]
|
|
689
|
-
seconds = sum(value * 60 ** index for index, value in enumerate(reversed(parts)))
|
|
690
|
-
return seconds + (int(days) * 86400 if days else 0)
|
|
686
|
+
# Match the executable and its entry script, not a wrapper that mentions the gate.
|
|
687
|
+
# --pid remains available for launchers/options whose argv ps cannot disambiguate.
|
|
688
|
+
GATE_ROOT = r'^(?:\S*/)?node(?:24)?(?:\s+--[^\s]+)*\s+(?:\S*/)?\.githooks/push-checks\.mjs(?:\s|$)'
|
|
691
689
|
|
|
692
690
|
|
|
693
|
-
def
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
691
|
+
def gate_candidates(output, pattern):
|
|
692
|
+
roots = []
|
|
693
|
+
for line in output.splitlines():
|
|
694
|
+
parts = line.split(None, 2)
|
|
695
|
+
if len(parts) == 3 and parts[0].isdigit() and parts[1].isdigit():
|
|
696
|
+
pid, uid = map(int, parts[:2])
|
|
697
|
+
if pid > 1 and pid != os.getpid() and uid == os.getuid() and pattern.search(parts[2]):
|
|
698
|
+
roots.append(pid)
|
|
699
|
+
return sorted(set(roots))
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
def choose_gate(roots):
|
|
703
|
+
if len(roots) > 1:
|
|
704
|
+
raise SystemExit('ambiguous gate roots; give --pid for the intended owner')
|
|
705
|
+
return roots[0] if roots else None
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
def observe_root(args):
|
|
709
|
+
if args.pid is not None:
|
|
710
|
+
return args.pid
|
|
698
711
|
pattern = re.compile(args.root)
|
|
699
|
-
|
|
700
|
-
while
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
root =
|
|
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
|
-
data
|
|
758
|
-
|
|
712
|
+
until = time.monotonic() + args.wait_seconds
|
|
713
|
+
while True:
|
|
714
|
+
try:
|
|
715
|
+
output = subprocess.run(['ps', '-axo', 'pid=,uid=,command='], check=True,
|
|
716
|
+
capture_output=True, text=True,
|
|
717
|
+
timeout=max(.05, min(5, until - time.monotonic()))).stdout
|
|
718
|
+
except subprocess.TimeoutExpired:
|
|
719
|
+
raise SystemExit('process inventory exceeded discovery deadline; give --pid or retry later')
|
|
720
|
+
root = choose_gate(gate_candidates(output, pattern))
|
|
721
|
+
if root is not None:
|
|
722
|
+
return root
|
|
723
|
+
if time.monotonic() >= until:
|
|
724
|
+
raise SystemExit('no matching gate before discovery deadline; give --pid or retry later')
|
|
725
|
+
time.sleep(min(args.interval, max(0, until - time.monotonic())))
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
def census_summary(report, status):
|
|
729
|
+
start, end, cpu, cpu_by_kind, samples = None, None, 0, collections.Counter(), 0
|
|
730
|
+
with report.open() as reader:
|
|
731
|
+
for line in reader:
|
|
732
|
+
row = json.loads(line)
|
|
733
|
+
if row['type'] == 'start':
|
|
734
|
+
start = row
|
|
735
|
+
elif row['type'] == 'sample':
|
|
736
|
+
samples += 1
|
|
737
|
+
for process in row['processes']:
|
|
738
|
+
delta = process['cpuDeltaNsLowerBound'] / 1e9
|
|
739
|
+
cpu += delta
|
|
740
|
+
cpu_by_kind[kind_of(process['name'])] += delta
|
|
741
|
+
elif row['type'] == 'end':
|
|
742
|
+
end = row
|
|
743
|
+
if start is None or end is None:
|
|
744
|
+
raise SystemExit(f'incomplete census; raw observation retained at {report}')
|
|
745
|
+
kinds = collections.Counter(kind_of(process['name']) for process in end['observedProcesses'])
|
|
746
|
+
return {'root': start['root'], 'startedAtMs': start['startedAtMs'],
|
|
747
|
+
'gateKind': 'unverified', 'rawReport': os.path.relpath(report, ROOT),
|
|
748
|
+
'observationWallSeconds': end['seconds'], 'sampledCpuSecondsLowerBound': cpu,
|
|
749
|
+
'averageObservedCpuCoresLowerBound': cpu / end['seconds'] if end['seconds'] else None,
|
|
750
|
+
'peakIntervalCpuCoresLowerBound': end['peak']['intervalCpuCoresLowerBound'],
|
|
751
|
+
'peakSummedRssMB': end['peak']['summedRssBytes'] / 2**20,
|
|
752
|
+
'peakProcesses': end['peak']['processes'], 'processes': len(end['observedProcesses']),
|
|
753
|
+
'processesByKind': dict(kinds), 'sampledCpuSecondsByKindLowerBound': dict(cpu_by_kind),
|
|
754
|
+
'remaining': end['remaining'], 'reason': end['reason'], 'incompleteReads': end['incompleteReads'],
|
|
755
|
+
'allObservedChildrenDrained': status == 0 and end['rootMeasured'] and not end['remaining']
|
|
756
|
+
and end['reason'] == 'observed tree drained',
|
|
757
|
+
'samples': samples, 'observerCpuSeconds': end['observerCpuNs'] / 1e9,
|
|
758
|
+
'limits': start['limits'],
|
|
759
|
+
'exactGateCpu': None,
|
|
760
|
+
'qualification': 'Not an exact full-gate total: attach full/split provenance and reaped-tree '
|
|
761
|
+
'user/system rusage separately. A sampled empty tree does not prove '
|
|
762
|
+
'that every short-lived descendant was observed.'}
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
def command_observe(args):
|
|
766
|
+
"""Observe existing owners through the identity-aware recorder; never launch or signal a gate."""
|
|
767
|
+
schema = 'vitest-gate-census/2'
|
|
768
|
+
if args.out.exists():
|
|
769
|
+
data = json.loads(args.out.read_text())
|
|
770
|
+
if data.get('schema') != schema or not isinstance(data.get('observations'), list):
|
|
771
|
+
raise SystemExit('incompatible census summary; use a new --out path for version 2 observations')
|
|
772
|
+
else:
|
|
773
|
+
data = {'schema': schema, 'observations': []}
|
|
774
|
+
args.out.parent.mkdir(parents=True, exist_ok=True)
|
|
775
|
+
for _ in range(args.count):
|
|
776
|
+
root = observe_root(args)
|
|
777
|
+
report = args.out.with_name(f'{args.out.stem}.{time.time_ns()}.{root}.jsonl')
|
|
778
|
+
command = [sys.executable, str(ROOT / 'scripts/cpu-census.py'), '--pid', str(root),
|
|
779
|
+
'--report', str(report), '--interval', str(args.interval), '--seconds', str(args.seconds),
|
|
780
|
+
'--drain-seconds', str(args.drain_seconds)]
|
|
781
|
+
print(f'observing root pid {root}; raw report {report}', flush=True)
|
|
782
|
+
result = subprocess.run(command, capture_output=True, text=True,
|
|
783
|
+
timeout=args.seconds + args.drain_seconds + 15)
|
|
784
|
+
if not report.exists():
|
|
785
|
+
raise SystemExit(result.stderr.strip() or 'census refused before observation')
|
|
786
|
+
row = census_summary(report, result.returncode)
|
|
787
|
+
data['observations'].append(row)
|
|
759
788
|
save(args.out, data)
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
789
|
+
print(json.dumps({'root': root, 'sampledCpuSecondsLowerBound': row['sampledCpuSecondsLowerBound'],
|
|
790
|
+
'allObservedChildrenDrained': row['allObservedChildrenDrained'],
|
|
791
|
+
'reason': row['reason']}), flush=True)
|
|
792
|
+
if result.returncode != 0:
|
|
793
|
+
raise SystemExit(result.returncode)
|
|
763
794
|
|
|
764
795
|
|
|
765
796
|
def main():
|
|
@@ -788,11 +819,25 @@ def main():
|
|
|
788
819
|
packer.add_argument('--workers', type=lambda text: [int(n) for n in text.split(',')], default=[2, 4, 5, 6, 8, 10])
|
|
789
820
|
packer.add_argument('--overhead', type=float, default=0.0, help='per-process startup seconds to subtract')
|
|
790
821
|
observe = sub.add_parser('observe')
|
|
791
|
-
observe.
|
|
792
|
-
|
|
822
|
+
roots = observe.add_mutually_exclusive_group()
|
|
823
|
+
roots.add_argument('--root', default=GATE_ROOT, help='anchored process-command regex; refuses ambiguous roots')
|
|
824
|
+
roots.add_argument('--pid', type=int, help='existing owner PID; observation never launches or signals it')
|
|
825
|
+
observe.add_argument('--out', type=Path, required=True, help='version-2 summary in your owned repository scratch')
|
|
826
|
+
observe.add_argument('--wait-seconds', type=float, default=120, help='discovery deadline, at most 120 seconds')
|
|
827
|
+
observe.add_argument('--seconds', type=float, default=1200, help='observation deadline, at most 3600 seconds')
|
|
828
|
+
observe.add_argument('--drain-seconds', type=float, default=10)
|
|
793
829
|
observe.add_argument('--interval', type=float, default=0.5)
|
|
794
830
|
observe.add_argument('--count', type=int, default=1)
|
|
795
831
|
args = parser.parse_args()
|
|
832
|
+
if args.command == 'observe':
|
|
833
|
+
if not .05 <= args.interval <= 10 or not 0 <= args.wait_seconds <= 120 or not 1 <= args.seconds <= 3600 or not 0 <= args.drain_seconds <= 30 or args.count < 1:
|
|
834
|
+
parser.error('give bounded observation/discovery intervals and a positive count')
|
|
835
|
+
if args.pid is not None and (args.pid <= 1 or args.pid == os.getpid() or args.count != 1):
|
|
836
|
+
parser.error('--pid needs one existing owner and --count=1')
|
|
837
|
+
try:
|
|
838
|
+
re.compile(args.root)
|
|
839
|
+
except re.error as error:
|
|
840
|
+
parser.error(f'invalid --root expression: {error}')
|
|
796
841
|
{'run': command_run, 'table': command_table, 'pack': command_pack, 'observe': command_observe}[args.command](args)
|
|
797
842
|
|
|
798
843
|
|
|
@@ -18,7 +18,11 @@ export const CI_NATIVE_GROUPS = {
|
|
|
18
18
|
// MP1C.4: a real crossing on the real clock, then a reboot; kept off sibling workers like net-fuzz's crossing.
|
|
19
19
|
'test/grid-crossing-crash.test.ts',
|
|
20
20
|
],
|
|
21
|
-
'native-direct-worker': [
|
|
21
|
+
'native-direct-worker': [
|
|
22
|
+
'test/headless-direct-worker.test.ts',
|
|
23
|
+
// Six real SDK workers, with a fixed 20 s parent fence: no sibling files.
|
|
24
|
+
'test/headless-verb-tape-worker.test.ts',
|
|
25
|
+
],
|
|
22
26
|
'native-host-transport': ['test/sim-transport.test.ts'],
|
|
23
27
|
'native-restores': [
|
|
24
28
|
'test/pinned-restore-play.test.ts',
|
package/scripts/vps/rebuild.sh
CHANGED
|
@@ -488,6 +488,8 @@ have_cook_source() {
|
|
|
488
488
|
&& [ "$(cook_commit)" = "$COOK_BUILD" ] \
|
|
489
489
|
&& [ "$(git -c safe.directory="$COOK_SRC" -C "$COOK_SRC" rev-parse "$COOK_REF^{commit}" 2>/dev/null)" = "$COOK_BUILD" ]
|
|
490
490
|
}
|
|
491
|
+
# pnpm 10 versions the store (`<store-dir>/v10`) and keeps the global virtual store at `<that>/links`, which
|
|
492
|
+
# scripts/assert-store-layout.mjs checks; `$COOK_PNPM_STORE/links` failed it, so v0.1.23's cook move rolled back.
|
|
491
493
|
make_cook_source() {
|
|
492
494
|
install -d -m 755 -o root -g root "$(dirname "$COOK_SRC")"
|
|
493
495
|
if [ ! -d "$COOK_SRC/.git" ]; then
|
|
@@ -498,7 +500,7 @@ make_cook_source() {
|
|
|
498
500
|
if [ "$(git -c safe.directory="$COOK_SRC" -C "$COOK_SRC" rev-parse "$COOK_REF^{commit}" 2>/dev/null)" != "$COOK_BUILD" ]; then say stop "The signed release's $COOK_REF does not resolve to $COOK_BUILD"; exit 1; fi
|
|
499
501
|
rm -f "$COOK_SRC/.wildshard-installed"
|
|
500
502
|
git -c safe.directory="$COOK_SRC" -C "$COOK_SRC" checkout --quiet --force --detach "$COOK_BUILD"
|
|
501
|
-
(cd "$COOK_SRC" && org_git env CI=1 HOME=/root COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack "$PNPM" install --frozen-lockfile --ignore-scripts --config.confirmModulesPurge=false --config.ci=false --store-dir "$COOK_PNPM_STORE" --virtual-store-dir "$COOK_PNPM_STORE/links")
|
|
503
|
+
(cd "$COOK_SRC" && org_git env CI=1 HOME=/root COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack "$PNPM" install --frozen-lockfile --ignore-scripts --config.confirmModulesPurge=false --config.ci=false --store-dir "$COOK_PNPM_STORE" --virtual-store-dir "$COOK_PNPM_STORE/v10/links")
|
|
502
504
|
(cd "$COOK_SRC" && "$NODE" scripts/assert-store-layout.mjs)
|
|
503
505
|
printf '%s %s\n' "$COOK_REF" "$COOK_BUILD" > "$COOK_SRC/.wildshard-installed"
|
|
504
506
|
chmod -R go-w "$COOK_SRC"
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
# wildshard-config cook <tag> AUTO-RELEASE AR4 (J355): move the cook worker to vX.Y.Z and
|
|
9
9
|
# the build a signed release names for it; roll back on failure
|
|
10
10
|
# wildshard-config show cook print the cook worker's tag and build
|
|
11
|
+
# wildshard-config saves list [--production] QA 11-15 row 24: every player's id, name and created_at
|
|
12
|
+
# wildshard-config saves delete-test <id>... [--production] [--yes]
|
|
13
|
+
# a test or bot player's rows, a dry run unless --yes
|
|
11
14
|
# Settings live in /etc/wildshard/<channel>.settings (640 root:wildshard-<channel>), which the units read after <channel>.env.
|
|
12
15
|
# Secrets stay in the root-only .env, and this never prints one or writes one (it reads only the placement rows there, for
|
|
13
16
|
# the pair check below): only the keys in SETTINGS below, each
|
|
@@ -274,9 +277,111 @@ def cook(args):
|
|
|
274
277
|
return 1
|
|
275
278
|
|
|
276
279
|
|
|
280
|
+
# QA 11-15 row 24 (Jake: "why dont you have an admin tool you can run on the VPS to clean it up yourself"): the agents clear
|
|
281
|
+
# the players their own probes and bots left in a saves database, and nobody else. Staging unless --production; a delete is a
|
|
282
|
+
# dry run unless --yes. Only a name a test or a bot takes can go: a probe's r<N><shard> (r13pine), the live proofs' Agent X,
|
|
283
|
+
# and Bot. Every table with a player_id column loses that player's rows and `player` its row, in one transaction that checks
|
|
284
|
+
# the names again under a row lock; the box journal (tag wildshard-saves) records each delete.
|
|
285
|
+
SAVES_ID = r'[A-Za-z0-9:._-]{1,128}'
|
|
286
|
+
TEST_NAMES = r'r[0-9]+[a-z][a-z0-9-]*|Agent( [A-Za-z0-9]+)+|[Bb]ot([ _-]?[A-Za-z0-9]+)?'
|
|
287
|
+
SAVES_MAX = 50
|
|
288
|
+
SAVES_TABLE = r'[a-z_][a-z0-9_]{0,62}'
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def psql(channel, sql, variables=None):
|
|
292
|
+
"""Rows (tab-separated fields) from SQL on the channel's saves database, run as postgres. The ids reach it only as psql
|
|
293
|
+
variables (:'ids'), never inside the SQL text."""
|
|
294
|
+
if TEST:
|
|
295
|
+
command = os.environ.get('WILDSHARD_CONFIG_TEST_PSQL', '/nonexistent').split(' ')
|
|
296
|
+
else:
|
|
297
|
+
command = ['/usr/sbin/runuser', '-u', 'postgres', '--', '/usr/bin/psql', '--cluster', '16/main', '-d', f'saves_{channel}']
|
|
298
|
+
command += ['-X', '-q', '-t', '-A', '-F', '\t', '-v', 'ON_ERROR_STOP=1']
|
|
299
|
+
for key, value in (variables or {}).items():
|
|
300
|
+
command += ['-v', f'{key}={value}']
|
|
301
|
+
try:
|
|
302
|
+
run = subprocess.run(command, input=sql, capture_output=True, text=True, cwd='/', env=helper_env())
|
|
303
|
+
except OSError as error:
|
|
304
|
+
stop(f'psql did not start: {error}')
|
|
305
|
+
if run.returncode != 0:
|
|
306
|
+
stop(f'psql on saves_{channel} exited {run.returncode}: {(run.stderr.strip().splitlines() or ["no message"])[-1]}')
|
|
307
|
+
return [line.split('\t') for line in run.stdout.splitlines() if line != '']
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def journal(line):
|
|
311
|
+
"""One line in the box journal, tag wildshard-saves; the test's stand-in logger instead (never as root)."""
|
|
312
|
+
logger = os.environ.get('WILDSHARD_CONFIG_TEST_LOGGER') if TEST else '/usr/bin/logger'
|
|
313
|
+
if logger:
|
|
314
|
+
subprocess.run([logger, '-t', 'wildshard-saves', '-p', 'auth.notice', '--', line], cwd='/', env=helper_env())
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def saves(args, production):
|
|
318
|
+
channel = 'production' if production else 'staging'
|
|
319
|
+
if args[1:2] == ['list'] and len(args) == 2:
|
|
320
|
+
for row in psql(channel, "select id, name, to_char(created_at at time zone 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') "
|
|
321
|
+
'from player order by created_at, id;'):
|
|
322
|
+
print(' '.join(row))
|
|
323
|
+
return 0
|
|
324
|
+
if args[1:2] != ['delete-test']:
|
|
325
|
+
stop('usage: wildshard-config saves list [--production] | saves delete-test <id>... [--production] [--yes]')
|
|
326
|
+
sure = '--yes' in args
|
|
327
|
+
ids = [arg for arg in args[2:] if arg != '--yes']
|
|
328
|
+
if not ids or len(ids) > SAVES_MAX or len(set(ids)) != len(ids):
|
|
329
|
+
stop(f'name 1 to {SAVES_MAX} player ids, none twice')
|
|
330
|
+
for player in ids:
|
|
331
|
+
if re.fullmatch(SAVES_ID, player) is None:
|
|
332
|
+
stop(f'{player!r} is not a player id (A-Z a-z 0-9 : . _ -)')
|
|
333
|
+
variables = {'ids': '{' + ','.join(f'"{player}"' for player in ids) + '}', 'names': f'^({TEST_NAMES})$', 'n': str(len(ids))}
|
|
334
|
+
names = dict(psql(channel, "select id, name from player where id = any(:'ids'::text[]);", variables))
|
|
335
|
+
missing = [player for player in ids if player not in names]
|
|
336
|
+
if missing:
|
|
337
|
+
stop(f'no player {", ".join(missing)} in saves_{channel}; nothing deleted')
|
|
338
|
+
kept = [f'{player} ({names[player]!r})' for player in ids if re.fullmatch(TEST_NAMES, names[player]) is None]
|
|
339
|
+
if kept:
|
|
340
|
+
stop(f'not a test or bot name, so refused: {", ".join(kept)}; nothing deleted')
|
|
341
|
+
tables = [row[0] for row in psql(channel, "select table_name from information_schema.columns where table_schema = 'public' "
|
|
342
|
+
"and column_name = 'player_id' and table_name <> 'player' order by table_name;")]
|
|
343
|
+
for table in tables:
|
|
344
|
+
if re.fullmatch(SAVES_TABLE, table) is None:
|
|
345
|
+
stop(f'unexpected table name {table!r}; nothing deleted')
|
|
346
|
+
counts = {}
|
|
347
|
+
if tables:
|
|
348
|
+
union = ' union all '.join(f"select '{table}', player_id, count(*) from public.\"{table}\" where player_id = any(:'ids'::text[]) "
|
|
349
|
+
'group by player_id' for table in tables)
|
|
350
|
+
for table, player, count in psql(channel, union + ';', variables):
|
|
351
|
+
counts.setdefault(player, []).append(f'{table} {count}')
|
|
352
|
+
for player in ids:
|
|
353
|
+
print(f'{"delete" if sure else "would":<7} saves_{channel} {player} {names[player]!r}: {", ".join(counts.get(player, [])) or "no rows"} and its player row')
|
|
354
|
+
if not sure:
|
|
355
|
+
print('dry run: nothing deleted; add --yes to delete')
|
|
356
|
+
return 0
|
|
357
|
+
# Under a row lock the names are read again, so a player who took a real name since is never deleted.
|
|
358
|
+
deletes = '\n'.join(f"with gone as (delete from public.\"{table}\" where player_id = any(:'ids'::text[]) returning 1) "
|
|
359
|
+
f"select '{table}', count(*) from gone;" for table in tables)
|
|
360
|
+
done = psql(channel, f"""begin;
|
|
361
|
+
select count(*) = :n as matched from (select id from player where id = any(:'ids'::text[]) and name ~ :'names' for update) locked \\gset
|
|
362
|
+
\\if :matched
|
|
363
|
+
{deletes}
|
|
364
|
+
with gone as (delete from player where id = any(:'ids'::text[]) returning 1) select 'player', count(*) from gone;
|
|
365
|
+
commit;
|
|
366
|
+
\\else
|
|
367
|
+
rollback;
|
|
368
|
+
select 'changed', 0;
|
|
369
|
+
\\endif
|
|
370
|
+
""", variables)
|
|
371
|
+
if ['changed', '0'] in done:
|
|
372
|
+
stop('a player changed its name or left while this ran; nothing deleted')
|
|
373
|
+
summary = ', '.join(f'{table} {count}' for table, count in done)
|
|
374
|
+
who = os.environ.get('SUDO_USER', 'root')
|
|
375
|
+
journal(f'saves delete-test saves_{channel} by {who}: ' + ' '.join(f'{player}={names[player]!r}' for player in ids) + f' ({summary})')
|
|
376
|
+
print(f'ok saves_{channel} deleted {summary}; the box journal has it (journalctl -t wildshard-saves)')
|
|
377
|
+
return 0
|
|
378
|
+
|
|
379
|
+
|
|
277
380
|
def main(argv):
|
|
278
381
|
production = '--production' in argv
|
|
279
382
|
args = [arg for arg in argv if arg != '--production']
|
|
383
|
+
if args and args[0] == 'saves':
|
|
384
|
+
return saves(args, production)
|
|
280
385
|
if args and args[0] == 'cook':
|
|
281
386
|
return cook(args)
|
|
282
387
|
if args[:2] == ['show', 'cook'] and len(args) == 2:
|
|
@@ -285,7 +390,7 @@ def main(argv):
|
|
|
285
390
|
stop('the cook worker moves with: wildshard-config cook vX.Y.Z')
|
|
286
391
|
if not args or args[0] not in ('show', 'set', 'split'):
|
|
287
392
|
stop('usage: wildshard-config show <channel> | set <channel> <KEY> <value> [<KEY> <value>]... [--production] | split <channel> '
|
|
288
|
-
'| cook vX.Y.Z | show cook')
|
|
393
|
+
'| cook vX.Y.Z | show cook | saves list|delete-test ...')
|
|
289
394
|
verb = args[0]
|
|
290
395
|
if len(args) < 2 or args[1] not in CHANNELS:
|
|
291
396
|
stop('the channel is production or staging')
|
|
@@ -3,15 +3,21 @@ import {existsSync} from 'node:fs';
|
|
|
3
3
|
import {open, readdir, realpath} from 'node:fs/promises';
|
|
4
4
|
import {dirname, join, resolve} from 'node:path';
|
|
5
5
|
import {pathToFileURL} from 'node:url';
|
|
6
|
-
import {
|
|
6
|
+
import {createRequire} from 'node:module';
|
|
7
7
|
|
|
8
8
|
/** The native control and its untimed disk preparation must select the same
|
|
9
9
|
* installed browser. Explicit selection wins, with no fallback after failure.
|
|
10
10
|
* @returns {string} */
|
|
11
11
|
export function nativeChromeExecutable() {
|
|
12
12
|
const candidates=[process.env.CHROME_PATH,process.env.CHROME_BIN,
|
|
13
|
-
...(process.platform==='linux'?['/usr/bin/google-chrome','/usr/bin/chromium']:[])
|
|
14
|
-
const
|
|
13
|
+
...(process.platform==='linux'?['/usr/bin/google-chrome','/usr/bin/chromium']:[])];
|
|
14
|
+
const selected=candidates.find(file=>file!==undefined&&existsSync(file));
|
|
15
|
+
if(selected!==undefined)return selected;
|
|
16
|
+
// Native controls with an explicit executable need no automation graph.
|
|
17
|
+
// Keep the ordinary installed-Playwright fallback for unprepared local runs.
|
|
18
|
+
const {chromium}=createRequire(import.meta.url)('playwright');
|
|
19
|
+
const fallback=chromium.executablePath();
|
|
20
|
+
const executable=existsSync(fallback)?fallback:undefined;
|
|
15
21
|
if(executable===undefined)throw new Error('No installed Chromium for the original trusted-input control');
|
|
16
22
|
return executable;
|
|
17
23
|
}
|
|
@@ -12,9 +12,12 @@ const listen = page => page.evaluate(() => {
|
|
|
12
12
|
for (const name of ['combat', 'sting']) record(world.music, name);
|
|
13
13
|
});
|
|
14
14
|
const heardOf = page => page.evaluate(() => (window.__said ?? []).slice(-14));
|
|
15
|
+
/** EG-15: when the census sets `sink`, it sees every page these journeys open (`opened`) and reads each one last as its context closes. */
|
|
16
|
+
export const pageCensus = { sink: null };
|
|
15
17
|
/** Open one shard with the row on, entered and on the wire. */
|
|
16
18
|
async function open(browser, phone, base, slug, query = '') {
|
|
17
|
-
const context = await browser.newContext(phone), page = await context.newPage(), errors = [];
|
|
19
|
+
const context = await browser.newContext(phone), page = await context.newPage(), errors = [], { sink } = pageCensus;
|
|
20
|
+
if (sink !== null) { const close = context.close.bind(context); context.close = async () => { await sink.closing(slug, page); return close(); }; }
|
|
18
21
|
page.on('pageerror', error => { errors.push(error.message.slice(0, 300)); });
|
|
19
22
|
page.on('console', line => { if (line.type() === 'error') errors.push(line.text().slice(0, 300)); });
|
|
20
23
|
await saveFixture(context, { scope: 'device', key: 'devMode', data: true });
|
|
@@ -23,8 +26,11 @@ async function open(browser, phone, base, slug, query = '') {
|
|
|
23
26
|
await page.waitForFunction(() => typeof window.__workerClient === 'function', undefined, { timeout: 150_000 });
|
|
24
27
|
await page.evaluate(FLOOR_GRID_ENTER);
|
|
25
28
|
await page.waitForFunction(() => window.__workerClient().frames > 30, undefined, { timeout: 60_000 });
|
|
29
|
+
if (sink !== null) sink.opened(slug, page);
|
|
26
30
|
return { context, page, errors };
|
|
27
31
|
}
|
|
32
|
+
/** A fresh boot of the same shard by its own URL, as a player reopens it. A reload can't: a started page drops its query, so it lands on the title. */
|
|
33
|
+
const reboot = (page, base, slug, query = '') => page.goto(new URL(`/?chunk=${slug}&mute=1&nolock=1${query}`, base).href, { waitUntil: 'load' });
|
|
28
34
|
const report = page => page.evaluate(() => window.__workerClient());
|
|
29
35
|
const fight = (page, id) => page.evaluate(want => window.__workerClientFights().find(row => row.id === want) ?? null, id);
|
|
30
36
|
const place = (page, x, y, z) => page.evaluate(([px, py, pz]) => { window.__wildshard.world.player.link.place(px, py, pz, 0); }, [x, y, z]);
|
|
@@ -721,7 +727,7 @@ async function qaraJourney(browser, phone, base, step) {
|
|
|
721
727
|
await step('qara: a save keeps him fallen and a page\'s fresh boot reads it back', async () => {
|
|
722
728
|
await page.evaluate(() => Promise.race([window.__workerClientSave(), new Promise(resolve => { setTimeout(resolve, 20_000); })]));
|
|
723
729
|
const before = await fight(page, id);
|
|
724
|
-
await page
|
|
730
|
+
await reboot(page, base, 'nalati-grasslands', '&bossGod');
|
|
725
731
|
await page.waitForFunction(() => window.__wildshard?.world?.player !== undefined, undefined, { timeout: 150_000 });
|
|
726
732
|
await page.waitForFunction(() => typeof window.__workerClient === 'function', undefined, { timeout: 150_000 });
|
|
727
733
|
await page.evaluate(FLOOR_GRID_ENTER);
|
|
@@ -810,7 +816,7 @@ async function qyranJourney(browser, phone, base, step) {
|
|
|
810
816
|
await step('qyran: a save keeps him fallen and a page\'s fresh boot reads it back', async () => {
|
|
811
817
|
await page.evaluate(() => Promise.race([window.__workerClientSave(), new Promise(resolve => { setTimeout(resolve, 20_000); })]));
|
|
812
818
|
const before = await fight(page, id);
|
|
813
|
-
await page
|
|
819
|
+
await reboot(page, base, 'nalati-grasslands');
|
|
814
820
|
await page.waitForFunction(() => window.__wildshard?.world?.player !== undefined, undefined, { timeout: 150_000 });
|
|
815
821
|
await page.waitForFunction(() => typeof window.__workerClient === 'function', undefined, { timeout: 150_000 });
|
|
816
822
|
await page.evaluate(FLOOR_GRID_ENTER);
|