1.9 KiB
1.9 KiB
IdleSpectator harness reference
Architecture
scripts/harness-run.sh
-> starts WorldBox if needed
-> writes IdleSpectator/.harness/commands.jsonl
-> touches reset + auto-dismiss
AgentHarness.Update() (in-game)
-> executes commands on Unity main thread
-> writes results.jsonl + last-result.json
-> logs [HARNESS]/[ASSERT]/[SNAP]
Why not OS input?
Wayland makes xdotool/ydotool unreliable.
Truth lives in engine state (MoveCamera, tips, settings), so drive the mod API directly.
Hard-won failure modes
| Symptom | Cause | Fix |
|---|---|---|
| Welcome closes, idle never starts | commands.jsonl rewritten same length; offset at EOF | runner writes offset=0 + reset |
| Steps run before world ready | wait_world requeued to back |
RequeueFront |
| Tip says crab, focus is angle | watch fell back to nearest unit | require matching asset; use pick_unit/asset=auto |
| Spawn then "no unit for asset" | miracle spawns die on bad tiles | prefer pick_unit for critical paths |
| Flaky health/no_bad mid-scenario | ambient retarget while harness busy | InterestDirector returns early when AgentHarness.Busy |
| Steam hang after tests | Application.Quit |
leave game running |
Useful asserts
health- idle + focus + power bar hidden +bad==0tip_matches_unit- tip asset equals focus unit asset; if tip starts withNew species:, label species must matchno_bad- StateProbe bad counter is zeroenabled- mod settingenabledbool
Extending scenarios
Edit IdleSpectator/HarnessScenarios.cs:
- Add steps with
Step(id, action, ...). - Register name in
Build. - Run
./scripts/harness-run.sh <name>then--repeat 3 critical_smoke.
Keep critical_smoke deterministic:
dismiss_windows/wait_worldfirstpick_unitbefore tip/focus assertsreset_countersafter spectator+focus before healthsimulate_inputlast for manual-exit coverage