Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ All notable changes will be documented here. The format follows [Keep a Changelo
- `FAD-0202` Secure local PNG icon resolution with trusted XDG roots, bounded caching, and traversal, symlink, malformed-file, and size protections.
- `FAD-0203` Flatpak-first canonical identity from bounded sandbox metadata and exported host desktop entries.
- `FAD-0204` Optional Snap identity from corroborated wrapper metadata without invoking or depending on Snap tooling.
- `FAD-0206` Advanced `fadrioctl inspect` diagnostics for canonical identity evidence and per-session audio state, with deterministic share-safe redaction.
- `REL-00003` Firefox qualification covers the installed `firefox-bin` runtime, one-row grouping, visible launcher/icon preference, ambiguity safety, and executable fallback.

### Changed

- `FAD-0205` XDG desktop-entry snapshots now refresh after debounced filesystem changes, advance a monotonic identity revision, and re-resolve active sessions once through the serialized mixer coordinator.
- `FAD-0206` Ordinary `fadrioctl apps` output no longer exposes process IDs; raw process and node details live in the explicit advanced inspector.
- `REL-00003` Visible XDG launchers now take precedence over hidden helpers when both have strong executable evidence; common `-bin` runtime names can match their launcher executable.

## [0.2.0-alpha.2] - 2026-09-13

Expand Down
1 change: 1 addition & 0 deletions Fadrio.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<Folder Name="/tests/">
<Project Path="tests/Fadrio.Core.Tests/Fadrio.Core.Tests.csproj" />
<Project Path="tests/Fadrio.Application.Tests/Fadrio.Application.Tests.csproj" />
<Project Path="tests/Fadrio.Cli.Tests/Fadrio.Cli.Tests.csproj" />
<Project Path="tests/Fadrio.Infrastructure.Tests/Fadrio.Infrastructure.Tests.csproj" />
<Project Path="tests/Fadrio.Platform.Linux.Tests/Fadrio.Platform.Linux.Tests.csproj" />
<Project Path="tests/Fadrio.NativeInterop.Tests/Fadrio.NativeInterop.Tests.csproj" />
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ Inspect current logical applications:
dotnet run --project src/Fadrio.Cli -- apps --watch
```

Inspect one application's resolver evidence and raw audio sessions explicitly:

```bash
dotnet run --project src/Fadrio.Cli -- inspect xdg:org.mozilla.firefox
dotnet run --project src/Fadrio.Cli -- inspect xdg:org.mozilla.firefox --redacted
```

Use `--redacted` before sharing output. The ordinary application list intentionally omits process IDs and raw node details.

Exercise the shared M0 command path:

```bash
Expand Down
8 changes: 6 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ Canonical ticket format:
- [x] `FAD-0205` `P1` Add resolver cache invalidation and desktop-index refresh watching.
- Scope: publish atomic XDG desktop-entry snapshots, debounce filesystem notifications, expose monotonic identity revisions, and re-resolve current sessions once when a new revision is observed.
- Acceptance: create, change, delete, refresh, disposal, failure-retry, and revision-initialization tests pass without watcher callbacks mutating mixer state directly.
- [ ] `FAD-0206` `P1` Add inspectable advanced identity/session diagnostics.
- [ ] `REL-00003` `P0` Qualify one-row Firefox identity, icons, ambiguity safety, and fallback behavior.
- [x] `FAD-0206` `P1` Add inspectable advanced identity/session diagnostics.
- Scope: add an explicit CLI inspector for canonical identity, resolver evidence, and raw per-session audio details; keep raw node and process information out of the ordinary application list; support share-safe redaction.
- Acceptance: deterministic renderer tests cover identity evidence, session ordering, sensitive-value redaction, and hostile control characters; the full managed/native validation pipeline passes.
- [x] `REL-00003` `P0` Qualify one-row Firefox identity, icons, ambiguity safety, and fallback behavior.
- Scope: qualify the installed Firefox `firefox-bin` runtime against visible and hidden XDG launchers, plus deterministic ambiguity and missing-metadata fallbacks.
- Acceptance: two real Firefox 156.0.1 streams group into one `xdg:firefox` row with the installed icon and High confidence; fixtures preserve safe executable fallback when visible candidates conflict or metadata is absent.

## 0.3 — Persistence

Expand Down
19 changes: 18 additions & 1 deletion docs/development/qualifying-browser.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Qualifying browser identity

`FAD-0012` qualifies browser multi-stream identity. Firefox-shaped fixtures retain deterministic coverage, while the real-browser observation uses the Brave installation available on the development host.
`FAD-0012` qualifies browser multi-stream identity. Firefox-shaped fixtures retain deterministic coverage, and `REL-00003` adds a real Firefox observation plus explicit ambiguity and fallback cases.

## Automated evidence

Expand Down Expand Up @@ -36,6 +36,23 @@ The following observation passed on 2026-09-04:

The fixture creates no network request and uses a very low-gain oscillator. Qualification output excludes runtime PIDs, profile paths, private browsing data, media titles, full command lines, and environment dumps.

## Real Firefox observation

The following observation passed on 2026-09-24:

- Zorin OS 18.1, Wayland GNOME session;
- Firefox 156.0.1 from the system package;
- PipeWire 1.0.5;
- two isolated Firefox profiles playing the repository's local low-gain Web Audio fixture;
- one `Firefox` application with canonical ID `xdg:firefox`, High confidence, the installed `firefox` icon, and two sessions;
- the real `/usr/lib/firefox/firefox-bin` runtime was reconciled with the visible `firefox.desktop` launcher;
- a hidden user-created launcher with an exact runtime path did not displace the visible application identity;
- setting volume to 35%, muting, and unmuting reached both Firefox sessions;
- terminating one profile reduced the row to one session, and its replacement rejoined the same identity as the second session;
- redacted advanced diagnostics exposed the evidence chain and both raw audio nodes without publishing process IDs, profile paths, or media names.

Deterministic fixtures also prove that competing visible Firefox launchers fall back to executable identity rather than guessing, and that missing desktop metadata produces the same stable executable fallback.

## Reproduction checklist

1. Launch two isolated browser profiles against `tests/fixtures/browser/brave-audio.html` with autoplay allowed.
Expand Down
94 changes: 94 additions & 0 deletions src/Fadrio.Cli/DiagnosticTextRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System.Globalization;
using System.Text;
using Fadrio.Core;

namespace Fadrio.Cli;

public static class DiagnosticTextRenderer
{
public static string Render(RuntimeApplication application, bool redacted)
{
ArgumentNullException.ThrowIfNull(application);

var output = new StringBuilder();
ApplicationIdentity identity = application.Identity;
Append(output, "Application", identity.DisplayName);
Append(output, "Canonical ID", identity.Id.Value);
Append(output, "Confidence", identity.Confidence.ToString());
Append(output, "Desktop file", identity.DesktopFileId);
Append(output, "Executable", Redact(identity.ExecutablePath, redacted));
Append(output, "Executable name", identity.ExecutableName);
Append(output, "Flatpak ID", identity.FlatpakId);
Append(output, "Snap ID", identity.SnapId);
Append(output, "Steam app ID", identity.SteamAppId);
Append(output, "Wine executable", Redact(identity.WineExecutable, redacted));
Append(output, "Icon", identity.Icon?.Value);

output.AppendLine();
output.Append("Identity evidence (")
.Append(identity.Evidence.Count.ToString(CultureInfo.InvariantCulture))
.AppendLine("): ");
if (identity.Evidence.Count == 0)
{
output.AppendLine(" (none)");
}
else
{
foreach (IdentityEvidence evidence in identity.Evidence
.OrderBy(item => item.Kind)
.ThenBy(item => item.Value, StringComparer.Ordinal))
{
bool sensitive = evidence.Kind is IdentityEvidenceKind.ProcessExecutable
or IdentityEvidenceKind.ProcessEnvironment;
string? value = sensitive ? Redact(evidence.Value, redacted) : evidence.Value;
output.Append(" - ")
.Append(evidence.Kind)
.Append(": ")
.Append(SingleLine(value))
.Append(" — ")
.AppendLine(SingleLine(evidence.Description));
}
}

output.AppendLine();
output.Append("Sessions (")
.Append(application.Sessions.Count.ToString(CultureInfo.InvariantCulture))
.AppendLine("): ");
foreach (AudioSession session in application.Sessions.OrderBy(item => item.PipeWireNodeId))
{
output.Append(" - Node ")
.Append(session.PipeWireNodeId.ToString(CultureInfo.InvariantCulture))
.Append(" | session ")
.AppendLine(SingleLine(session.Id.Value));
Append(output, " Process ID", Redact(session.ProcessId?.ToString(CultureInfo.InvariantCulture), redacted));
Append(output, " Application name", session.ApplicationName);
Append(output, " PipeWire app ID", session.ApplicationId);
Append(output, " Process binary", session.ProcessBinary);
Append(output, " Media name", Redact(session.MediaName, redacted));
Append(output, " Media role", session.MediaRole);
Append(output, " Output device", session.OutputDevice?.Value);
Append(output, " Volume",
string.Concat((session.Volume * 100f).ToString("0.#", CultureInfo.InvariantCulture), "%"));
Append(output, " Muted", session.Muted.ToString().ToLowerInvariant());
Append(output, " Active", session.Active.ToString().ToLowerInvariant());
}

if (redacted)
{
output.AppendLine();
output.AppendLine("Sensitive process paths, process IDs, media names, and process evidence were redacted.");
}

return output.ToString();
}

private static string? Redact(string? value, bool redacted) =>
redacted && !string.IsNullOrWhiteSpace(value) ? "(redacted)" : value;

private static void Append(StringBuilder output, string label, string? value) =>
output.Append(label).Append(": ").AppendLine(SingleLine(value));

private static string SingleLine(string? value) => string.IsNullOrWhiteSpace(value)
? "(none)"
: value.Replace('\r', ' ').Replace('\n', ' ').Replace('\t', ' ').Trim();
}
26 changes: 18 additions & 8 deletions src/Fadrio.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
using Fadrio.Application;
using Fadrio.Cli;
using Fadrio.Infrastructure;
using Fadrio.NativeInterop;
using Fadrio.Platform.Linux;

string command = args.FirstOrDefault() ?? "apps";
if (command is not ("apps" or "set" or "mute" or "unmute"))
if (command is not ("apps" or "inspect" or "set" or "mute" or "unmute"))
{
PrintUsage();
return 2;
}

bool watch = command == "apps" && args.Contains("--watch", StringComparer.Ordinal);
if ((command == "set" && args.Length != 3) ||
(command is "mute" or "unmute" && args.Length != 2))
(command is "mute" or "unmute" && args.Length != 2) ||
(command == "inspect" && (args.Length is < 2 or > 3 ||
(args.Length == 3 && args[2] != "--redacted"))))
{
PrintUsage();
return 2;
Expand Down Expand Up @@ -53,16 +56,21 @@
}
else if (command != "apps")
{
var mixerCommands = new MixerCommands(backend, coordinator);
var applicationId = new Fadrio.Core.ApplicationId(args[1]);
if (coordinator.Current.Applications.All(application => application.Identity.Id != applicationId))
Fadrio.Core.RuntimeApplication? application = coordinator.Current.Applications
.SingleOrDefault(candidate => candidate.Identity.Id == applicationId);
if (application is null)
{
Console.Error.WriteLine($"Application '{applicationId}' is not currently available.");
shutdown.Cancel();
await IgnoreCancellationAsync(coordinatorTask);
return 1;
}
if (command == "set")
if (command == "inspect")
{
Console.Write(DiagnosticTextRenderer.Render(application, args.Contains("--redacted", StringComparer.Ordinal)));
}
else if (command == "set")
{
if (!float.TryParse(args[2], System.Globalization.NumberStyles.Float,
System.Globalization.CultureInfo.InvariantCulture, out float percentage) ||
Expand All @@ -71,13 +79,15 @@
Console.Error.WriteLine("Volume must be a number from 0 to 100.");
return 2;
}
await mixerCommands.SetApplicationVolumeAsync(applicationId, percentage / 100f, shutdown.Token);
await new MixerCommands(backend, coordinator)
.SetApplicationVolumeAsync(applicationId, percentage / 100f, shutdown.Token);
Console.WriteLine($"Set {applicationId} to {percentage:0.#}% across all current sessions.");
}
else
{
bool muted = command == "mute";
await mixerCommands.SetApplicationMuteAsync(applicationId, muted, shutdown.Token);
await new MixerCommands(backend, coordinator)
.SetApplicationMuteAsync(applicationId, muted, shutdown.Token);
Console.WriteLine($"{(muted ? "Muted" : "Unmuted")} {applicationId} across all current sessions.");
}
}
Expand All @@ -104,6 +114,7 @@ static void PrintUsage()
{
Console.Error.WriteLine("Usage:");
Console.Error.WriteLine(" fadrioctl apps [--watch]");
Console.Error.WriteLine(" fadrioctl inspect <canonical-id> [--redacted]");
Console.Error.WriteLine(" fadrioctl set <canonical-id> <0-100>");
Console.Error.WriteLine(" fadrioctl mute <canonical-id>");
Console.Error.WriteLine(" fadrioctl unmute <canonical-id>");
Expand Down Expand Up @@ -139,7 +150,6 @@ static void Print(Fadrio.Core.MixerSnapshot snapshot)
Console.WriteLine($"Canonical ID: {application.Identity.Id}");
Console.WriteLine($"Confidence: {application.Identity.Confidence}");
Console.WriteLine($"Sessions: {application.Sessions.Count}");
Console.WriteLine($"Processes: {string.Join(", ", application.Sessions.Select(session => session.ProcessId).Where(id => id.HasValue).Select(id => id!.Value))}");
string percentage = (application.EffectiveVolume * 100f).ToString("0", System.Globalization.CultureInfo.InvariantCulture);
Console.WriteLine($"Volume: {percentage}%{(application.IsMixedVolume ? " (mixed)" : string.Empty)}");
Console.WriteLine($"Muted: {application.IsMuted.ToString().ToLowerInvariant()}");
Expand Down
8 changes: 7 additions & 1 deletion src/Fadrio.Infrastructure/XdgDesktopApplicationIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public IReadOnlyList<DesktopApplicationEntry> FindByExecutable(string executable
DesktopApplicationEntry[] entries = Volatile.Read(ref _entries);
DesktopApplicationEntry[] matches = entries.Where(entry => entry.Executable is not null &&
(PathEquals(entry.Executable, executablePath) ||
Path.GetFileName(entry.Executable).Equals(name, StringComparison.OrdinalIgnoreCase)))
ExecutableNamesMatch(Path.GetFileName(entry.Executable), name)))
.ToArray();
DesktopApplicationEntry[] visible = matches.Where(entry => !entry.NoDisplay).ToArray();
// A hidden URL handler can share its application's executable and icon.
Expand Down Expand Up @@ -209,4 +209,10 @@ private void RefreshSafely()
private static bool PathEquals(string left, string right) =>
Path.IsPathRooted(left) && Path.IsPathRooted(right) &&
Path.GetFullPath(left).Equals(Path.GetFullPath(right), StringComparison.Ordinal);

private static bool ExecutableNamesMatch(string left, string right) =>
NormalizeExecutableName(left).Equals(NormalizeExecutableName(right), StringComparison.OrdinalIgnoreCase);

private static string NormalizeExecutableName(string value) =>
value.EndsWith("-bin", StringComparison.OrdinalIgnoreCase) ? value[..^4] : value;
}
6 changes: 5 additions & 1 deletion src/Fadrio.Platform.Linux/ApplicationResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ await steamApplications.TryResolveAsync(session, process, cancellationToken).Con
AddIdMatches(desktopApplications.FindById(iconName), 70, "PipeWire icon name");
}

DesktopCandidate[] ranked = candidates.Values
IEnumerable<DesktopCandidate> eligibleCandidates = candidates.Values.Any(candidate =>
!candidate.Entry.NoDisplay && candidate.Score >= MinimumDesktopScore)
? candidates.Values.Where(candidate => !candidate.Entry.NoDisplay)
: candidates.Values;
DesktopCandidate[] ranked = eligibleCandidates
.OrderByDescending(candidate => candidate.Score)
.ThenBy(candidate => candidate.Entry.Id, StringComparer.OrdinalIgnoreCase)
.ToArray();
Expand Down
Loading
Loading