feat: enforce typed legacy probe input roles

This commit is contained in:
codex
2026-08-05 16:12:55 +03:00
parent 02e34186fc
commit 9c49ebf1e2
4 changed files with 36 additions and 7 deletions
@@ -4,20 +4,19 @@ using Launcher.Next.Core;
namespace Launcher.Next.Application;
public sealed record LegacyConfigurationProbeRequest(LauncherPathVariables Paths, string PatternName, LegacyCompatibilityOverlay Overlay, string OperationId);
public sealed record LegacyConfigurationProbeRequest(ResolvedLegacySettingsPath Settings, ResolvedLegacyDownloadListPath DownloadList, ResolvedLegacyProbeEvidenceRoot EvidenceRoot, string PatternName, LegacyCompatibilityOverlay Overlay, string OperationId);
public sealed record LegacyConfigurationProbeResult(string TerminalState, IReadOnlyList<PackageRequirement> Requirements, string EvidencePath, IReadOnlyList<string> Diagnostics);
/// <summary>Read-only configuration inspection. It intentionally has no package,
/// activation, process, or Autodesk dependency.</summary>
public sealed class LegacyConfigurationProbe(LegacyConfigurationAdapter adapter, IPathResolver resolver)
public sealed class LegacyConfigurationProbe(LegacyConfigurationAdapter adapter)
{
public async Task<LegacyConfigurationProbeResult> RunAsync(LegacyConfigurationProbeRequest request, CancellationToken cancellationToken = default)
{
var paths = resolver.Resolve(request.Paths, ["LegacySettingsPath", "LegacyDownloadListPath", "LegacyProbeEvidenceRoot"]);
var settingsPath = resolver.ResolvePath(paths.Require("LegacySettingsPath"), request.Paths);
var selectionPath = resolver.ResolvePath(paths.Require("LegacyDownloadListPath"), request.Paths);
var evidenceRoot = resolver.ResolvePath(paths.Require("LegacyProbeEvidenceRoot"), request.Paths);
if (!File.Exists(settingsPath) || !File.Exists(selectionPath) || Path.GetFullPath(evidenceRoot).StartsWith(@"\\", StringComparison.Ordinal)) throw new InvalidOperationException("LEGACY_PROBE_INPUT_PATH_INVALID");
var settingsPath = request.Settings.Value;
var selectionPath = request.DownloadList.Value;
var evidenceRoot = request.EvidenceRoot.Value;
if (!File.Exists(settingsPath) || !File.Exists(selectionPath)) throw new InvalidOperationException("LEGACY_PROBE_INPUT_PATH_INVALID");
if (Path.GetDirectoryName(settingsPath)!.Equals(evidenceRoot, StringComparison.OrdinalIgnoreCase) || Path.GetDirectoryName(selectionPath)!.Equals(evidenceRoot, StringComparison.OrdinalIgnoreCase)) throw new InvalidOperationException("PATH_ROLE_COLLISION");
Directory.CreateDirectory(evidenceRoot);
var before = await Snapshot(settingsPath, selectionPath, cancellationToken);