fix(core): tell value-type Auto settings without advice from an advised default

Auto<T>.Resolve returned default instead of the fallback for value types
because AutoValue cannot be null there. Auto<T> now records HasAdvice;
the render pipeline's ProjectValues workaround and the advisor's
ReasonKey heuristic are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 12:26:17 +00:00
1 parent 5774592c44
commit f78a76513c
9 files changed
+41 -61

No files matched your search

+7 -3
View File
@@ -9,9 +9,13 @@ public sealed record Auto<T>
{
public bool IsAuto { get; init; } = true;
/// <summary>The advisor's value (null until analysis provides one).</summary>
/// <summary>The advisor's value; meaningful only when <see cref="HasAdvice"/>.</summary>
public T? AutoValue { get; init; }
/// <summary>True once the advisor stored a value. Needed because a value type's <see cref="AutoValue"/> is never
/// null: without it "no advice" and an advised 0 or false look the same.</summary>
public bool HasAdvice { get; init; }
/// <summary>The user's value when <see cref="IsAuto"/> is false.</summary>
public T? Manual { get; init; }
@@ -21,11 +25,11 @@ public sealed record Auto<T>
public IReadOnlyList<string>? ReasonArgs { get; init; }
/// <summary>The value in force: manual when set by the user, otherwise the advisor's, otherwise <paramref name="fallback"/>.</summary>
public T Resolve(T fallback) => !IsAuto && Manual is not null ? Manual : AutoValue ?? fallback;
public T Resolve(T fallback) => !IsAuto && Manual is not null ? Manual : HasAdvice && AutoValue is not null ? AutoValue : fallback;
public Auto<T> WithManual(T value) => this with { IsAuto = false, Manual = value };
public Auto<T> Reset() => this with { IsAuto = true, Manual = default };
public Auto<T> WithAdvice(T value, string? reasonKey, params string[] args) => this with { AutoValue = value, ReasonKey = reasonKey, ReasonArgs = args };
public Auto<T> WithAdvice(T value, string? reasonKey, params string[] args) => this with { AutoValue = value, HasAdvice = true, ReasonKey = reasonKey, ReasonArgs = args };
}