diff --git a/architecture.md b/architecture.md index 430fdf0..bd85ab2 100644 --- a/architecture.md +++ b/architecture.md @@ -234,7 +234,9 @@ All durable application data is TOML: profiles, device profiles/bindings, active - `~/.local/state/fader_master/state.toml`: schema version, per-profile confirmed object/channel state and separately validated desired object volume/mute, remembered assignments, last selected UI view. No ephemeral backend handles or pending operation IDs; cached observations are marked stale until refreshed. Desired values may include commands issued offline, but are applied after restart only under explicit restore policy. When no explicit profile path is supplied, a missing active selection creates a -minimal `default` profile before atomically publishing its active pointer. A +safe `default` profile with a pickup-enabled default-output fader before +atomically publishing its active pointer. This provides a useful keyboard mixer +and a target for MIDI Learn without guessing application identities. A missing profile named by an existing valid active pointer is initialized with that stable ID. Existing files, malformed selections, and explicit missing paths are never overwritten by this first-run recovery. diff --git a/config/src/document.rs b/config/src/document.rs index bb68a3f..99f7844 100644 --- a/config/src/document.rs +++ b/config/src/document.rs @@ -28,7 +28,7 @@ pub struct ProfileDocument { } impl ProfileDocument { - /// Builds a valid profile with no configured objects or MIDI surfaces. + /// Builds a safe first-run profile with a default-output fader and no MIDI surfaces. pub fn empty(id: &str) -> Result { Self::parse(&format!( r#"schema_version = 1 @@ -40,6 +40,12 @@ new_stream = "adopt" adapter = "auto" preference = ["pulse", "pipewire"] max_gain = 1.0 + +[[faders]] +id = "master-fader" +target = {{ kind = "output", id = "default" }} +pickup = true +pickup_tolerance = 0.02 "# )) } diff --git a/fader_master/src/application.rs b/fader_master/src/application.rs index b1ef65e..7d3b091 100644 --- a/fader_master/src/application.rs +++ b/fader_master/src/application.rs @@ -437,7 +437,13 @@ mod tests { let document = ProfileDocument::parse(&fs::read_to_string(&profile_path).unwrap()).unwrap(); let profile = document.preview().unwrap(); assert_eq!(profile.id().as_str(), "default"); - assert!(profile.faders().is_empty()); + assert_eq!(profile.faders().len(), 1); + assert_eq!(profile.faders()[0].id(), "master-fader"); + assert_eq!( + profile.faders()[0].target_kind(), + fader_config::TargetKind::Output + ); + assert_eq!(profile.faders()[0].target_id(), "default"); } #[test] diff --git a/task.md b/task.md index 628a499..869ba39 100644 --- a/task.md +++ b/task.md @@ -476,12 +476,14 @@ Dependencies: all required feature milestones; hardware-only ALSA remains an exp - [ ] **M12.1 Adversarial replay:** deterministic reconnect/churn/write-failure/echo/reordered-event/profile-switch scenarios. Property tests preserve domain invariants; command storms stay bounded and converge without starving mute or shutdown. - [ ] **M12.2 Integration matrix:** PulseAudio, pipewire-pulse, native PipeWire, two controllers, external desktop mixer, reload/restart, read-only/full state directory. Record fixtures, supported device profiles and known limitations; never run destructive audio tests on the user's current session by default. - [ ] **M12.3 Packaging:** example TOML profiles, schema/migration documentation, build/install guide, optional systemd user unit and troubleshooting. Acceptance: fresh user install can discover, bind, edit, save, restart and reconnect without root or manual state repair. - Managed startup now initializes a valid empty `default` profile and active + Managed startup now initializes a valid `default` profile and active pointer on first run, and recreates only a missing profile referenced by a valid existing pointer. Explicit paths and malformed existing files remain errors rather than being overwritten. Pre-versioned/schema-0 profiles upgrade automatically only after full candidate validation, with comment preservation, an exact `.v0.bak` backup, and atomic replacement. + New managed profiles include a safe default-output fader so first-run setup + has an editable mixer target before any application or controller is known. - [ ] **M12.4 Release gates:** all workspace/default/feature/MSRV checks, reproducible lockfile, license review and dependency advisory review using maintained tooling selected at implementation time. Measure/control latency under multi-surface load and publish the tested envelope. ## User requirement coverage