Add Muninn Quest access surface

This commit is contained in:
Meta Vens 2026-06-12 16:09:03 +01:00
commit d5345e5875
8 changed files with 492 additions and 6 deletions

View file

@ -266,6 +266,16 @@ fn swarm_targets(options: &SwarmOptions) -> Result<Vec<DaemonTarget>> {
enabled: true,
interval_seconds: 60,
},
DaemonTarget {
daemon_id: "starfire-muninn".to_string(),
verse_id: "starfire.local".to_string(),
name: "Starfire Muninn telemetry and Quest access daemon".to_string(),
health_command: Some(script("health-starfire-muninn.cmd")),
deploy_command: None,
restart_command: Some(script("restart-starfire-muninn.cmd")),
enabled: true,
interval_seconds: 30,
},
DaemonTarget {
daemon_id: "muninn".to_string(),
verse_id: "raven.local".to_string(),

View file

@ -5,7 +5,8 @@ use cultmesh_rs::{
};
use odin_core::{
MuninnCaptureStreamRecord, MuninnMoveControllerStateRecord, MuninnMoveLightCommandRecord,
MuninnObsStreamCatalogRecord, MuninnTelemetrySurfaceRecord, OdinDocuments,
MuninnObsStreamCatalogRecord, MuninnQuestAccessRecord, MuninnTelemetrySurfaceRecord,
OdinDocuments,
};
use serde::Serialize;
use std::env;
@ -30,6 +31,7 @@ enum Mode {
RequestMoveLight,
MoveLightStatus,
MoveStateStatus,
QuestAccessStatus,
}
#[derive(Clone, Debug, PartialEq, Eq)]
@ -65,6 +67,11 @@ struct Options {
move_evidence_verse_id: String,
move_evidence_ring_slots: usize,
move_evidence_slot_bytes: usize,
quest_adb: bool,
quest_serial: Option<String>,
quest_input_stream_id: Option<String>,
quest_pose_stream_id: Option<String>,
quest_video_input_stream_id: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
@ -143,6 +150,7 @@ fn main() -> Result<()> {
Mode::RequestMoveLight => request_move_light(options),
Mode::MoveLightStatus => move_light_status(options),
Mode::MoveStateStatus => move_state_status(options),
Mode::QuestAccessStatus => quest_access_status(options),
Mode::DryRun => {
let plan = build_mux_plan(&options, "dry-run".to_string());
println!("{}", plan.command_line);
@ -178,6 +186,7 @@ fn serve(options: Options) -> Result<()> {
&mut HidMoveControllerStateReader,
move_evidence_stream.as_mut(),
)?;
publish_quest_access_if_requested(&mut node, &options)?;
publish_surface(&mut node, &options, "idle", &[])?;
if options.interval_seconds.is_none()
&& active_move_lights.is_empty()
@ -279,6 +288,9 @@ fn publish_surface(
"audio.loopback.wasapi".to_string(),
"psmove.light.command".to_string(),
"psmove.controller.state".to_string(),
"quest.usb.access".to_string(),
"quest.input.openxr.witness".to_string(),
"quest.video.warp_corrected_input".to_string(),
"audio.input.enumeration.pending".to_string(),
"video.input.enumeration.pending".to_string(),
],
@ -297,7 +309,7 @@ fn publish_surface(
}
fn available_sources(options: &Options) -> Vec<String> {
vec![
let mut sources = vec![
format!("screen:ddagrab:output_idx={}", options.ddagrab_output_index),
format!(
"audio-loopback:wasapi:{}:{}ch@{}",
@ -305,7 +317,19 @@ fn available_sources(options: &Options) -> Vec<String> {
),
"sensor:microphone:enumeration-pending".to_string(),
"sensor:camera:enumeration-pending".to_string(),
]
];
if options.quest_adb {
sources.push(format!(
"sensor:quest:adb:{}",
options
.quest_serial
.as_deref()
.unwrap_or("any-authorized-quest")
));
} else {
sources.push("sensor:quest:adb:activation-required".to_string());
}
sources
}
fn publish_stream(
@ -988,6 +1012,169 @@ fn parse_move_color(color: &str) -> Result<(u8, u8, u8)> {
Ok((red, green, blue))
}
fn publish_quest_access_if_requested(
node: &mut cultmesh_rs::CultMeshNode,
options: &Options,
) -> Result<()> {
if !options.quest_adb {
return Ok(());
}
let record = probe_quest_access(options)?;
node.put("quest-access", &record)?;
node.put(&record.access_id, &record)?;
Ok(())
}
fn probe_quest_access(options: &Options) -> Result<MuninnQuestAccessRecord> {
let output = Command::new("adb")
.args(["devices", "-l"])
.output()
.context("running adb devices -l for Quest access")?;
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
if !output.status.success() {
return build_quest_access_record(
options,
ParsedQuestDevice::default(),
"unavailable",
&format!("adb devices -l failed: {}", stderr.trim()),
);
}
let parsed = parse_quest_device_from_adb(&stdout, options.quest_serial.as_deref());
let parsed_device = parsed.unwrap_or_default();
let (state, detail): (String, String) = match &parsed_device {
device if device.connection_state == "device" => (
"usb-authorized".to_string(),
"Quest is authorized over USB. Muninn can publish access and route Quest input/video surfaces; tracked poses still require a Quest/OpenXR witness.".to_string(),
),
device if device.serial.is_empty() => (
"unavailable".to_string(),
"No matching Quest device was found in adb devices -l.".to_string(),
),
device => (
device.connection_state.clone(),
"Quest is visible over USB but not authorized for local access.".to_string(),
),
};
build_quest_access_record(options, parsed_device, &state, &detail)
}
fn build_quest_access_record(
options: &Options,
device: ParsedQuestDevice,
state: &str,
detail: &str,
) -> Result<MuninnQuestAccessRecord> {
let serial = if device.serial.is_empty() {
options
.quest_serial
.clone()
.unwrap_or_else(|| "unknown".to_string())
} else {
device.serial
};
Ok(MuninnQuestAccessRecord {
access_id: format!("muninn:{}:quest-access:{}", options.host_id, serial),
host_id: options.host_id.clone(),
serial,
connection_state: device.connection_state,
product: device.product,
model: device.model,
device: device.device,
transport_id: device.transport_id,
input_stream_id: options
.quest_input_stream_id
.clone()
.unwrap_or_else(|| format!("muninn:{}:quest-input", options.host_id)),
pose_stream_id: options
.quest_pose_stream_id
.clone()
.unwrap_or_else(|| format!("muninn:{}:quest-poses", options.host_id)),
video_input_stream_id: options
.quest_video_input_stream_id
.clone()
.unwrap_or_else(|| format!("muninn:{}:quest-warped-video-input", options.host_id)),
video_input_transport: "brokkr-unity-editor-warped-frame-stream".to_string(),
state: state.to_string(),
detail: detail.to_string(),
observed_at: timestamp()?,
})
}
#[derive(Clone, Debug, Default, PartialEq, Eq)]
struct ParsedQuestDevice {
serial: String,
connection_state: String,
product: String,
model: String,
device: String,
transport_id: String,
}
fn parse_quest_device_from_adb(
adb_devices_output: &str,
requested_serial: Option<&str>,
) -> Option<ParsedQuestDevice> {
adb_devices_output
.lines()
.filter_map(parse_adb_device_line)
.find(|device| {
if let Some(serial) = requested_serial {
return device.serial == serial;
}
device.model.contains("Quest")
|| device.product == "hollywood"
|| device.device == "hollywood"
})
}
fn parse_adb_device_line(line: &str) -> Option<ParsedQuestDevice> {
let tokens: Vec<&str> = line.split_whitespace().collect();
if tokens.len() < 2 || tokens[0] == "List" {
return None;
}
let mut device = ParsedQuestDevice {
serial: tokens[0].to_string(),
connection_state: tokens[1].to_string(),
..ParsedQuestDevice::default()
};
for token in tokens.iter().skip(2) {
let Some((key, value)) = token.split_once(':') else {
continue;
};
match key {
"product" => device.product = value.to_string(),
"model" => device.model = value.to_string(),
"device" => device.device = value.to_string(),
"transport_id" => device.transport_id = value.to_string(),
_ => {}
}
}
Some(device)
}
fn quest_access_status(options: Options) -> Result<()> {
let node = open_node(&options, "muninn-quest-access-status")?;
let record = node
.get_required::<MuninnQuestAccessRecord>("quest-access")
.context("Muninn Quest access record is unavailable")?;
println!(
"{} state={} model={} product={} input={} poses={} video={} detail={}",
record.serial,
record.state,
record.model,
record.product,
record.input_stream_id,
record.pose_stream_id,
record.video_input_stream_id,
record.detail
);
Ok(())
}
fn health_check(options: &Options) -> Result<()> {
let node = open_node(options, "muninn-health")?;
let surface = node
@ -1290,6 +1477,11 @@ impl Options {
move_evidence_verse_id: "mimir-live".to_string(),
move_evidence_ring_slots: 4,
move_evidence_slot_bytes: 8192,
quest_adb: false,
quest_serial: None,
quest_input_stream_id: None,
quest_pose_stream_id: None,
quest_video_input_stream_id: None,
};
let mut args = args.peekable();
@ -1300,6 +1492,7 @@ impl Options {
"request-move-light" => options.mode = Mode::RequestMoveLight,
"move-light-status" => options.mode = Mode::MoveLightStatus,
"move-state-status" => options.mode = Mode::MoveStateStatus,
"quest-access-status" => options.mode = Mode::QuestAccessStatus,
"--health" => options.mode = Mode::Health,
"--dry-run" => options.mode = Mode::DryRun,
"--store" => options.store_path = PathBuf::from(take_value(&mut args, "--store")?),
@ -1372,6 +1565,22 @@ impl Options {
.parse()
.context("--move-evidence-slot-bytes must be a positive integer")?
}
"--quest-adb" => options.quest_adb = true,
"--quest-serial" => {
options.quest_serial = Some(take_value(&mut args, "--quest-serial")?)
}
"--quest-input-stream" => {
options.quest_input_stream_id =
Some(take_value(&mut args, "--quest-input-stream")?)
}
"--quest-pose-stream" => {
options.quest_pose_stream_id =
Some(take_value(&mut args, "--quest-pose-stream")?)
}
"--quest-video-input-stream" => {
options.quest_video_input_stream_id =
Some(take_value(&mut args, "--quest-video-input-stream")?)
}
"--color" => options.move_colors.push(take_value(&mut args, "--color")?),
"--duration-ms" => options
.move_durations_ms
@ -1415,6 +1624,22 @@ impl Options {
"--move-evidence-slot-bytes must be greater than zero"
));
}
for (name, value) in [
("--quest-serial", options.quest_serial.as_ref()),
(
"--quest-input-stream",
options.quest_input_stream_id.as_ref(),
),
("--quest-pose-stream", options.quest_pose_stream_id.as_ref()),
(
"--quest-video-input-stream",
options.quest_video_input_stream_id.as_ref(),
),
] {
if value.is_some_and(|value| value.trim().is_empty()) {
return Err(anyhow!("{name} must be non-empty"));
}
}
Ok(options)
}
}
@ -1441,7 +1666,7 @@ fn timestamp_ns() -> Result<i64> {
}
fn help_text() -> &'static str {
"Usage: muninn [serve|activate|request-move-light|move-light-status|move-state-status] [--store <path>] [--target-host <host>] [--port <port>] [--obs-target-host <host>] [--obs-port <port>] [--loopback-script <path>] [--ffmpeg <path>] [--move-state <move-id>=<hidraw-path>] [--move-evidence-stream <stream-id>] [--move-evidence-verse <verse-id>] [--dry-run] [--health]\n\nMuninn is Odin's portable telemetry Verse assembler. serve publishes cheap typed telemetry affordances, optional source-local Move controller state, and a CultMesh Move evidence stream when Move state sources are attached; activate starts an explicitly requested local stream; request-move-light publishes a typed Move light command for Muninn serve to execute; move-light-status reads typed command receipts; move-state-status reads typed controller-state records."
"Usage: muninn [serve|activate|request-move-light|move-light-status|move-state-status|quest-access-status] [--store <path>] [--target-host <host>] [--port <port>] [--obs-target-host <host>] [--obs-port <port>] [--loopback-script <path>] [--ffmpeg <path>] [--move-state <move-id>=<hidraw-path>] [--move-evidence-stream <stream-id>] [--move-evidence-verse <verse-id>] [--quest-adb] [--quest-serial <serial>] [--quest-input-stream <stream-id>] [--quest-pose-stream <stream-id>] [--quest-video-input-stream <stream-id>] [--dry-run] [--health]\n\nMuninn is Odin's portable telemetry Verse assembler. serve publishes cheap typed telemetry affordances, optional source-local Move controller state, optional Quest USB access surfaces, and a CultMesh Move evidence stream when Move state sources are attached; activate starts an explicitly requested local stream; request-move-light publishes a typed Move light command for Muninn serve to execute; move-light-status reads typed command receipts; move-state-status reads typed controller-state records; quest-access-status reads typed Quest access state."
}
fn parse_move_state_source(value: &str) -> Result<MoveStateSource> {
@ -1704,6 +1929,87 @@ mod tests {
assert_eq!(options.move_evidence_verse_id, "mimir-live");
}
#[test]
fn serve_accepts_quest_access_streams() {
let options = Options::parse(
[
"serve",
"--host",
"starfire",
"--quest-adb",
"--quest-serial",
"1WMHHB68PG1515",
"--quest-input-stream",
"muninn:starfire:quest-input",
"--quest-pose-stream",
"muninn:starfire:quest-poses",
"--quest-video-input-stream",
"muninn:starfire:quest-warped-video-input",
]
.into_iter()
.map(String::from),
)
.unwrap();
assert!(options.quest_adb);
assert_eq!(options.quest_serial.as_deref(), Some("1WMHHB68PG1515"));
assert_eq!(
options.quest_video_input_stream_id.as_deref(),
Some("muninn:starfire:quest-warped-video-input")
);
}
#[test]
fn parses_authorized_quest_from_adb_devices() {
let output = "List of devices attached\n1WMHHB68PG1515 device product:hollywood model:Quest_2 device:hollywood transport_id:5\n";
let device = parse_quest_device_from_adb(output, None).expect("Quest should parse");
assert_eq!(device.serial, "1WMHHB68PG1515");
assert_eq!(device.connection_state, "device");
assert_eq!(device.product, "hollywood");
assert_eq!(device.model, "Quest_2");
assert_eq!(device.transport_id, "5");
}
#[test]
fn quest_access_record_defaults_streams_to_host_owned_muninn_surfaces() {
let options = Options::parse(
["serve", "--host", "starfire", "--quest-adb"]
.into_iter()
.map(String::from),
)
.unwrap();
let record = build_quest_access_record(
&options,
ParsedQuestDevice {
serial: "1WMHHB68PG1515".to_string(),
connection_state: "device".to_string(),
product: "hollywood".to_string(),
model: "Quest_2".to_string(),
device: "hollywood".to_string(),
transport_id: "5".to_string(),
},
"usb-authorized",
"test",
)
.unwrap();
assert_eq!(
record.access_id,
"muninn:starfire:quest-access:1WMHHB68PG1515"
);
assert_eq!(record.input_stream_id, "muninn:starfire:quest-input");
assert_eq!(record.pose_stream_id, "muninn:starfire:quest-poses");
assert_eq!(
record.video_input_stream_id,
"muninn:starfire:quest-warped-video-input"
);
assert_eq!(
record.video_input_transport,
"brokkr-unity-editor-warped-frame-stream"
);
}
#[derive(Deserialize)]
struct DecodedMoveEvidenceStreamFrame(
String,

View file

@ -25,6 +25,7 @@ pub const MUNINN_OBS_STREAM_CATALOG_SCHEMA: &str = "muninn.obs_stream_catalog.v1
pub const MUNINN_MOVE_MARKER_CANDIDATE_SCHEMA: &str = "muninn.move_marker_candidate.v1";
pub const MUNINN_MOVE_CONTROLLER_STATE_SCHEMA: &str = "muninn.move_controller_state.v1";
pub const MUNINN_MOVE_LIGHT_COMMAND_SCHEMA: &str = "muninn.move_light_command.v1";
pub const MUNINN_QUEST_ACCESS_SCHEMA: &str = "muninn.quest_access.v1";
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "odin.snapshot", schema = "odin.snapshot.v1")]
@ -515,6 +516,41 @@ pub struct MuninnMoveLightCommandRecord {
pub updated_at: String,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "muninn.quest_access", schema = "muninn.quest_access.v1")]
pub struct MuninnQuestAccessRecord {
#[cultcache(key = 0)]
pub access_id: String,
#[cultcache(key = 1)]
pub host_id: String,
#[cultcache(key = 2)]
pub serial: String,
#[cultcache(key = 3)]
pub connection_state: String,
#[cultcache(key = 4)]
pub product: String,
#[cultcache(key = 5)]
pub model: String,
#[cultcache(key = 6)]
pub device: String,
#[cultcache(key = 7)]
pub transport_id: String,
#[cultcache(key = 8)]
pub input_stream_id: String,
#[cultcache(key = 9)]
pub pose_stream_id: String,
#[cultcache(key = 10)]
pub video_input_stream_id: String,
#[cultcache(key = 11)]
pub video_input_transport: String,
#[cultcache(key = 12)]
pub state: String,
#[cultcache(key = 13)]
pub detail: String,
#[cultcache(key = 14)]
pub observed_at: String,
}
cultmesh_rs::cultmesh_documents!(OdinDocuments {
OdinSnapshotRecord => ODIN_SNAPSHOT_SCHEMA,
OdinVerseRecord => ODIN_VERSE_SCHEMA,
@ -540,6 +576,7 @@ cultmesh_rs::cultmesh_documents!(OdinDocuments {
MuninnMoveMarkerCandidateRecord => MUNINN_MOVE_MARKER_CANDIDATE_SCHEMA,
MuninnMoveControllerStateRecord => MUNINN_MOVE_CONTROLLER_STATE_SCHEMA,
MuninnMoveLightCommandRecord => MUNINN_MOVE_LIGHT_COMMAND_SCHEMA,
MuninnQuestAccessRecord => MUNINN_QUEST_ACCESS_SCHEMA,
});
#[derive(Clone, Debug, Default, PartialEq, Eq)]

View file

@ -13,8 +13,8 @@ microphones, cameras, and future sensors.
- Inputs: cheap local probes, operator or Verse activation requests, and local
capture tools such as FFmpeg or WASAPI helpers.
- Outputs: `muninn.telemetry_surface.v1`, active `muninn.capture_stream.v1`,
Move receipt records, and a CultMesh bytes stream carrying live Move evidence
frames for Mimir.
Quest access records, Move receipt records, and a CultMesh bytes stream
carrying live Move evidence frames for Mimir.
- Forbidden writers: daemon startup, Idunn keepalive, Mimir ingest, OBS, Odin,
Gjallar, and renderer bodies must not start capture by implication.
@ -52,6 +52,52 @@ That Raven activation starts the requested screen and Realtek loopback stream
and publishes `muninn.capture_stream.v1`. Mimir and OBS are stream consumers;
they do not own Muninn.
## Quest Access And Unity Return Video
Quest hardware attached to Starfire is a Muninn local telemetry surface, not a
Mimir-owned preflight. Enable it by running Muninn on Starfire with ADB probing:
```powershell
muninn serve `
--store C:\Meta\Odin\state\muninn.telemetry.cc `
--host starfire `
--quest-adb `
--quest-serial 1WMHHB68PG1515
```
When `adb devices -l` reports the Quest as `device`, Muninn publishes
`muninn.quest_access.v1` at `quest-access` and
`muninn:<host>:quest-access:<serial>`. The record advertises:
- `muninn:<host>:quest-input`: Quest buttons/analog/controller input once a
Quest/OpenXR witness is running.
- `muninn:<host>:quest-poses`: headset and controller poses from that same
witness.
- `muninn:<host>:quest-warped-video-input`: warp-corrected video frames that
Brokkr can route from Starfire Unity editor play mode toward the Quest device.
ADB authorization proves local USB access only. It does not by itself expose
OpenXR poses or accept video frames. A Quest/OpenXR witness still owns headset
runtime sampling, while Brokkr owns the Unity editor adapter that sends
warp-corrected play-mode frames to Muninn's advertised Quest video input.
Read the current record with:
```powershell
muninn quest-access-status --store C:\Meta\Odin\state\muninn.telemetry.cc
```
For Starfire's local Quest-attached daemon, Idunn supervises the
`starfire-muninn` target through:
```powershell
E:\Projects\Odin\scripts\restart-starfire-muninn.cmd
E:\Projects\Odin\scripts\health-starfire-muninn.cmd
```
The restart script launches Muninn hidden with `--host starfire --quest-adb`
and stores state in `C:\Meta\Odin\state\starfire.muninn.telemetry.cc`.
The deployed loopback helper must accept Muninn's command contract:
```powershell

View file

@ -0,0 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\health-starfire-muninn.ps1

View file

@ -0,0 +1,30 @@
param(
[string] $MuninnExe = "C:\Meta\Odin\Muninn\muninn.exe",
[string] $StorePath = "C:\Meta\Odin\state\starfire.muninn.telemetry.cc"
)
$ErrorActionPreference = "Stop"
if (-not (Test-Path -LiteralPath $MuninnExe)) {
throw "Muninn executable not found at $MuninnExe"
}
$process = Get-CimInstance Win32_Process |
Where-Object {
$_.Name -ieq "muninn.exe" -and
$_.CommandLine -like "*serve*" -and
$_.CommandLine -like "*--host*starfire*" -and
$_.CommandLine -like "*--quest-adb*"
} |
Select-Object -First 1
if ($null -eq $process) {
throw "Starfire Muninn serve process is not running with Quest access enabled"
}
& $MuninnExe --health --store $StorePath
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
& $MuninnExe quest-access-status --store $StorePath
exit $LASTEXITCODE

View file

@ -0,0 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\restart-starfire-muninn.ps1

View file

@ -0,0 +1,53 @@
param(
[string] $MuninnExe = "C:\Meta\Odin\Muninn\muninn.exe",
[string] $StorePath = "C:\Meta\Odin\state\starfire.muninn.telemetry.cc",
[string] $LogRoot = "C:\Meta\Odin\logs\starfire-muninn",
[string] $QuestSerial = "1WMHHB68PG1515"
)
$ErrorActionPreference = "Stop"
if (-not (Test-Path -LiteralPath $MuninnExe)) {
throw "Muninn executable not found at $MuninnExe"
}
Get-CimInstance Win32_Process |
Where-Object {
$_.Name -ieq "muninn.exe" -and
$_.CommandLine -like "*serve*" -and
$_.CommandLine -like "*--host*starfire*"
} |
ForEach-Object {
& taskkill.exe /PID $_.ProcessId /T /F | Out-Null
}
New-Item -ItemType Directory -Force -Path $LogRoot | Out-Null
$storeParent = Split-Path -Parent $StorePath
if (-not [string]::IsNullOrWhiteSpace($storeParent)) {
New-Item -ItemType Directory -Force -Path $storeParent | Out-Null
}
$arguments = @(
"serve",
"--store", $StorePath,
"--log-root", $LogRoot,
"--host", "starfire",
"--interval-seconds", "15",
"--quest-adb",
"--quest-serial", $QuestSerial
)
$process = Start-Process `
-FilePath $MuninnExe `
-ArgumentList $arguments `
-WindowStyle Hidden `
-PassThru `
-RedirectStandardOutput (Join-Path $LogRoot "muninn-serve.out.log") `
-RedirectStandardError (Join-Path $LogRoot "muninn-serve.err.log")
$process.Id | Set-Content -Encoding ASCII -LiteralPath (Join-Path $LogRoot "muninn-serve.pid")
Start-Sleep -Seconds 2
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "health-starfire-muninn.ps1") `
-MuninnExe $MuninnExe `
-StorePath $StorePath