fix(scripts): reset-aware handshake refuses a null reset value; document additive timeouts (#36 review)

A null resetValue encoded to null, which wrote an empty string and then handed the
waiter a null target (= any change), fast-pathing on the stale cache and reinstating
the race the overload exists to close. The context parameter is now non-nullable and
the accessor throws ArgumentException before any write. Also: additive-timeout note on
all surfaces, batch-failure message no longer names the bool overload, and the
error-message/batch-failure branches are pinned.

Claude-Session: https://claude.ai/code/session_01XPsuy2ZZ5Gbyfpt8PrK5BV
This commit is contained in:
Joseph Doherty
2026-09-10 15:35:50 -04:00
parent 637da6c020
commit 17d5d3e639
8 changed files with 138 additions and 12 deletions
@@ -341,7 +341,11 @@ public sealed class ScriptCompileSurface
/// <param name="responseValue">The value to wait for on the response attribute.</param>
/// <param name="timeout">The maximum time to wait for the response.</param>
/// <param name="resetKey">The attribute written first and waited on before the batch.</param>
/// <param name="resetValue">The reset value the device must echo before the batch is written.</param>
/// <param name="resetValue">
/// The reset value the device must echo before the batch is written. MUST NOT be null — the
/// real accessor throws <see cref="System.ArgumentException"/>, because a null would write an
/// empty string and then wait on "any change", reinstating the race the overload closes.
/// </param>
/// <param name="resetTimeout">The maximum time to wait for the reset echo; <c>null</c> means <paramref name="timeout"/>.</param>
/// <returns>The phase-aware handshake outcome.</returns>
public Task<HandshakeResult> WriteBatchAndWaitAsync(IReadOnlyDictionary<string, object?> values, string flagKey, object? flagValue, string responseKey, object? responseValue, TimeSpan timeout, string resetKey, object? resetValue, TimeSpan? resetTimeout = null) => throw new NotSupportedException(CompileOnly);