fix(headless): S1 ACDREAM_HEADLESS_CONSOLE=0 disables even on a real terminal

HeadlessConsoleOptions.Resolve tested the environment variable against
the literal "1", so ACDREAM_HEADLESS_CONSOLE=0 silently fell through to
the terminal-shaped default (on when stdin is a real console) instead of
acting as an A/B off-switch. Now: once the variable is SET AT ALL, any
value other than "0" enables and "0" disables -- the same idiom
ACDREAM_RETAIL_CLOSE_DEGRADES / ACDREAM_RETAIL_UI already use. An unset
variable still falls through to the terminal default.

Registered the flag as the sixth entry in
LaunchOptionsDocumentationTests.DefaultOnBehaviorFlags and updated the
Conventions section of docs/launch-options.md plus the flag's own row
(side-effects column corrected to describe the real precedence).

ResolvePrefersFlagThenEnvironmentThenTerminalDefault's env="0"/terminal
=true case was shown to fail against the prior `== "1"` implementation
(expected false, old code returned true) before the fix landed; the
env="yes" case also failed on the same mutation (old code required the
literal "1", so "yes" fell through to terminal=false instead of enabling).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-09-07 07:51:41 +02:00
parent c01ae15825
commit 55e454aedc
4 changed files with 48 additions and 18 deletions

View file

@ -107,10 +107,14 @@ public sealed class LaunchOptionsDocumentationTests
}
/// <summary>
/// The five flags that default ON. All are product/retail behaviors wearing an
/// A/B off-switch (<c>=0</c> disables) — none is a diagnostic. FROZEN:
/// a diagnostic that activates without its env var set taxes every run
/// and every measurement silently, so growing this set fails.
/// The six flags that default ON. All are product/retail behaviors wearing an
/// A/B off-switch (<c>=0</c> disables) — none is a diagnostic.
/// <c>ACDREAM_HEADLESS_CONSOLE</c> (added 2026-09-07, S1 fix round) is the
/// odd one out: its UNSET default is terminal-shaped, not unconditionally
/// on — but once it is SET AT ALL it reads the identical <c>=0</c>-disables
/// idiom this regex detects, so it belongs in this set on the same terms.
/// FROZEN: a diagnostic that activates without its env var set taxes every
/// run and every measurement silently, so growing this set fails.
/// </summary>
private static readonly IReadOnlySet<string> DefaultOnBehaviorFlags =
new HashSet<string>(StringComparer.Ordinal)
@ -120,6 +124,7 @@ public sealed class LaunchOptionsDocumentationTests
"ACDREAM_CAMERA_ALIGN_SLOPE",
"ACDREAM_RETAIL_CLOSE_DEGRADES",
"ACDREAM_RETAIL_UI",
"ACDREAM_HEADLESS_CONSOLE",
};
/// <summary>
@ -134,7 +139,7 @@ public sealed class LaunchOptionsDocumentationTests
RegexOptions.Compiled);
[Fact]
public void OnlyTheFiveProductBehaviorFlagsDefaultOn()
public void OnlyTheSixProductBehaviorFlagsDefaultOn()
{
var defaultOn = new HashSet<string>(StringComparer.Ordinal);
foreach ((string path, _) in SourceFiles())

View file

@ -31,10 +31,16 @@ public sealed class HeadlessConsoleTests
// ── HeadlessConsoleOptions (typed option resolution) ─────────────────
[Theory]
[InlineData(true, "0", false, true)] // CLI flag always wins
[InlineData(false, "1", false, true)] // env var wins over terminal default
[InlineData(false, "0", true, true)] // env var "0" does not disable the terminal default
[InlineData(false, null, true, true)] // no flag/env -> terminal-shaped default (on)
[InlineData(true, "0", false, true)] // CLI flag always wins, even over env "0"
[InlineData(false, "1", false, true)] // env var "1" wins over terminal default
[InlineData(false, "yes", false, true)] // any non-"0" env value enables (RETAIL_CLOSE_DEGRADES/RETAIL_UI idiom)
// S1 fix (2026-09-07 review round): ACDREAM_HEADLESS_CONSOLE=0 must
// disable the console even when stdin IS a real terminal — the earlier
// `== "1"` test let "0" silently fall through to the terminal-shaped
// default instead of acting as the documented A/B off-switch.
[InlineData(false, "0", true, false)] // env var "0" disables even when stdin is a terminal
[InlineData(false, "0", false, false)] // env var "0" disables when stdin is redirected too
[InlineData(false, null, true, true)] // no flag/env -> terminal-shaped default (on)
[InlineData(false, null, false, false)] // no flag/env -> terminal-shaped default (off)
public void ResolvePrefersFlagThenEnvironmentThenTerminalDefault(
bool commandLineFlag,