feat: seed first-run profiles with a master fader

Give newly initialized managed profiles a safe pickup-enabled default-output fader so the mixer and MIDI Learn have a usable target before application discovery.

Tests: cargo test -p fader_master managed_startup_initializes_missing_active_selection_and_profile --all-features; cargo test -p fader-config --test schema mixer_layout_defaults_to_declared_faders_and_validates_explicit_entries
This commit is contained in:
Dandaedre 2026-10-16 18:58:08 +02:00
parent 944e005914
commit e5239e3243
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
4 changed files with 20 additions and 4 deletions

View File

@ -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.

View File

@ -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, ConfigError> {
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
"#
))
}

View File

@ -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]

View File

@ -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