HydraIssues

hydrabody: lift the XR directive state machine out of the Windows build
open unclassified Priority: medium Project: hydrabody Parent: #781 Reporter: 14 Oct 2026 20:47

Description

BLOCKER for the whole WiVRn lane. Everything else under #781 waits on this.

What is wrong

pkg/provider/alvr_other.go:7-13 stubs out tickALVR, xrStartupEvidenceCheck and superviseXROffline on every non-Windows platform. The engine is in pkg/provider/alvr_windows.go (953 lines) behind //go:build windows.

A WiVRn body therefore advertises xr_drivers:["wivrn"] honestly, the cluster matches a head to it and writes an XR directive into the body status response, and the body drops the directive on the floor. storeXRDirective is reachable (it is in the platform-neutral alvr.go) but takeXRDirective is only called from tickALVR, which does nothing here. wivrnArm in pkg/provider/wivrn_linux.go:14 is dead code reached by no path.

Symptom on hardware: the head requests a session, the cluster says requested, the body never moves to arming, and the head sits until its connect timeout.

The split

The file divides cleanly at resolveSteamPath (line 624).

Driver-agnostic, lines 44 to 623, these move to a new pkg/provider/xr_session.go with no build tag:
tickALVR (rename, it is the generic tick), xrAdoptDirective, xrStartupEvidenceCheck,
startXRArm, armXR, superviseXROffline, superviseXR, xrEnterActive,
teardownXR, stateLabel, postXRStatusNow

ALVR and Windows only, lines 624 onward, these stay put:
resolveSteamPath, alvrStartChain, alvrLaunchDashboard, alvrLaunchSteamVR,
resolveVRStartup, alvrDashboardRequest, alvrTrustClient, alvrClientConnected,
alvrDashboardShowsConnected, alvrStreamSocketConnected, alvrOpenvrPathsFiles,
alvrDriverRegistered, alvrRegisterDriver, alvrUnregisterDriver, superviseALVRChain

Three more need a platform twin rather than a move:
quiesceSunshineForXR already has a Linux handle. desktop_linux.go was generalised to
desktopService(action, unit), so stopping hydra-sunshine.service on Linux is one call.
xrResolveExperienceExe and xrEnsureExperienceRunning are not needed on the WiVRn lane at
all: WiVRn launches the application itself from its own config. See the config render child.
stop_linux.go already carries killExperienceProcesses for teardown, matching the resolved
/proc//exe because comm truncates at 15 characters.

Shape

Put arm, disarm, serving and clientConnected behind a small interface chosen by the directive's Driver field. wivrn_linux.go already supplies three of the four. alvr_windows.go supplies the ALVR implementation. The state machine itself stops knowing which driver it drives.

Note alvr_windows.go:179 already rejects a directive whose Driver is not alvr, so the dispatch point exists; it just needs to select rather than reject.

Care

xrCapable in alvr.go:57 requires the alvr role AND the ALVR install directory, so it is false on Linux by construction. Do not widen it: xrDrivers in wivrn.go:52 is the function that ORs the two capabilities together, and it is already correct. The guards at alvr_windows.go:47 and :141 are the ones that need to become driver-aware.

Done when

An Omarchy body with the wivrn role moves through arming, armed, active and draining on a real session, and a Windows ALVR body still behaves byte for byte as it does today. Unit coverage for the state machine runs on Linux, which it cannot do at all now.

Session Context

Venue
mobile-kit

Comments (1)

api 15 Oct 2026 11:23

How to start this with no prior context

Read #796 first for the system, the vocabulary and the hard rules. Then this. You need nothing else.

Set up

cd ~/hydrabody
git -C . log --oneline -3          # confirm you are on master and clean
df -h /                            # the workstation runs near full; a Go build needs headroom

If go build fails with no space left on device, stop and tell the owner. Do not clear ~/go/pkg/mod, because re-fetching private dependencies needs a per-repo GOPRIVATE_TOKEN.

Establish the baseline BEFORE you touch anything

This change is a refactor of code that runs on Windows bodies that are live in venues. The only acceptance that matters is that the ALVR path still behaves identically. So record the baseline first:

GOOS=windows GOARCH=amd64 go build ./...
GOOS=linux   GOARCH=amd64 go build ./...
go vet ./pkg/provider/
go test ./pkg/provider/

All four must pass before you start. If they do not, that is a separate problem and this issue is blocked.

Read these three files before editing

  • pkg/provider/alvr_windows.go (953 lines) is the engine being split. The issue body lists which function goes where.
  • pkg/provider/alvr_other.go (13 lines) is the no-op stub that causes the bug. Read it first, it is the whole problem in one screen.
  • pkg/provider/wivrn_linux.go already supplies wivrnArm, wivrnDisarm and wivrnServing. Your job is to make something call them, not to write them.

Also skim pkg/provider/alvr.go, which is already platform-neutral and holds the state constants, the capability checks and the directive store. It shows the pattern to follow.

What correct looks like

This is a behaviour-preserving move, not a redesign. Nothing about how an ALVR body behaves may change. The commit should be almost entirely cut and paste, plus an interface and a dispatch.

Specifically:

  • A Windows ALVR body arms, streams and tears down exactly as before. Same states, same timings, same log lines.
  • A Linux body with the wivrn role now reads the directive and calls wivrnArm.
  • Both targets build, vet and test clean.
  • The state machine no longer mentions any driver by name. It asks an interface.

Do not take the opportunity to improve the state machine while moving it. If you find a bug in it, file a separate issue and leave it behaving as it does.

How to prove it

A green build is not proof, and in this fleet a green build has three times proved nothing. Prove it on the hardware:

  • The test body is msi1060, an Omarchy machine in the mobile-kit venue. Reach it through the cluster API and cluster exec, not SSH.
  • Test only against bxl1-test* districts. Never a production body or head.
  • The body should move through arming, armed, active and draining on a real session, visible in its status reports to the cluster.

Note that active is not reachable until #783 lands, since nothing yet detects that the headset connected. Reaching armed with the WiVRn server actually running is the bar for this issue.

When you are done

  • Commit to master directly. This repo uses no PR ceremony.
  • Do not deploy by hand. Releases go CI to registry, then the land pulls.
  • Comment here with what you proved and on which machine, then close. Close when it is deployed and verified, not when it compiles.
  • Next in the sequence is #783. Do not start it in the same commit.