fix(galaxy): Pending/Warning status rows map to Uncertain; detail 8001 to BadTypeMismatch (#872)
v2-ci / unit-tests (push) Has been cancelled
v2-ci / unit-tests (push) Has been cancelled
Owner decision 2026-11-13 on #872 item 1. StatusCodeMap.FromMxStatus now maps a Pending or Warning row to Uncertain (0x40000000) for any detail, ahead of the detail vocabulary, keeping the once-per-(detail, category) warning. MXAccess sets success = -1 on Pending (accepted, in progress); neither category is a failure. Detail 8001 (automation-object ConfigurationError, write rejected for type conversion, live-captured on windev 2026-11-13) maps to BadTypeMismatch. 8018 stays BadUserAccessDenied via its SecurityError category, now pinned by a test. Data change: the value is published Uncertain. Write reply: the result is Uncertain, never Good, so the server (which commits only Good) reports the write not committed and reverts the node; a later MXAccess commit arrives as a data change. Host status is unchanged (probe decode treats Uncertain and Bad alike, quality < 192 -> Unknown); no alarm path calls the map. Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
This commit is contained in:
@@ -75,6 +75,18 @@ public sealed class EventPumpQualityTests
|
||||
public async Task An_ok_status_row_is_graded_by_the_item_quality(int quality, uint expected)
|
||||
=> (await PublishedStatusAsync(quality, Ok)).ShouldBe(expected);
|
||||
|
||||
/// <summary>#872: a Pending or Warning status row on a data change publishes the value Uncertain, not Bad.</summary>
|
||||
[Theory]
|
||||
[InlineData(MxStatusCategory.Pending, -1, 0)]
|
||||
[InlineData(MxStatusCategory.Pending, -1, 1007)]
|
||||
[InlineData(MxStatusCategory.Warning, 0, 0)]
|
||||
[InlineData(MxStatusCategory.Warning, 0, 2)]
|
||||
public async Task A_pending_or_warning_status_row_publishes_uncertain(MxStatusCategory category, int success, int detail)
|
||||
{
|
||||
var row = new MxStatusProxy { Success = success, Category = category, Detail = detail };
|
||||
(await PublishedStatusAsync(192, row)).ShouldBe(StatusCodeMap.Uncertain);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task A_failure_status_row_wins_over_a_good_quality()
|
||||
{
|
||||
|
||||
+43
@@ -176,6 +176,49 @@ public sealed class GatewayGalaxyDataWriterFailClosedTests
|
||||
unconfirmed.Total.ShouldBe(0); // NOT empty-statuses ⇒ not metered unconfirmed
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #872: a Pending or Warning row on the write reply is Uncertain — never Good (MXAccess did not confirm
|
||||
/// the commit, so the server must not report the write committed) and never plain Bad.
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[InlineData(MxStatusCategory.Pending, -1, 0)]
|
||||
[InlineData(MxStatusCategory.Pending, -1, 1007)]
|
||||
[InlineData(MxStatusCategory.Warning, 0, 0)]
|
||||
[InlineData(MxStatusCategory.Warning, 0, 1004)]
|
||||
public async Task WriteOne_PendingOrWarningStatusRow_ReturnsUncertain(MxStatusCategory category, int success, int detail)
|
||||
{
|
||||
var reply = new MxCommandReply { ProtocolStatus = new ProtocolStatus { Code = ProtocolStatusCode.Ok } };
|
||||
reply.Statuses.Add(new MxStatusProxy { Success = success, Category = category, Detail = detail });
|
||||
var ops = new FakeMxWriteOps
|
||||
{
|
||||
InvokeResponder = _ => new MxCommandReply { ProtocolStatus = new ProtocolStatus { Code = ProtocolStatusCode.Ok } },
|
||||
RawWriteResponder = () => reply,
|
||||
};
|
||||
var writer = NewWriter();
|
||||
|
||||
var result = await writer.WriteOneForTestAsync(ops, new WriteRequest("Tag.P", 3), SecurityClassification.FreeAccess, CancellationToken.None);
|
||||
|
||||
result.StatusCode.ShouldBe(StatusCodeMap.Uncertain);
|
||||
}
|
||||
|
||||
/// <summary>#872: the live 8001 write refusal (string written to a double) returns BadTypeMismatch.</summary>
|
||||
[Fact]
|
||||
public async Task WriteOne_Detail8001Reply_ReturnsBadTypeMismatch()
|
||||
{
|
||||
var reply = new MxCommandReply { ProtocolStatus = new ProtocolStatus { Code = ProtocolStatusCode.Ok } };
|
||||
reply.Statuses.Add(new MxStatusProxy { Success = 0, Category = MxStatusCategory.ConfigurationError, Detail = 8001, RawDetectedBy = 5 });
|
||||
var ops = new FakeMxWriteOps
|
||||
{
|
||||
InvokeResponder = _ => new MxCommandReply { ProtocolStatus = new ProtocolStatus { Code = ProtocolStatusCode.Ok } },
|
||||
RawWriteResponder = () => reply,
|
||||
};
|
||||
var writer = NewWriter();
|
||||
|
||||
var result = await writer.WriteOneForTestAsync(ops, new WriteRequest("Tag.T", "abc"), SecurityClassification.FreeAccess, CancellationToken.None);
|
||||
|
||||
result.StatusCode.ShouldBe(StatusCodeMap.BadTypeMismatch);
|
||||
}
|
||||
|
||||
// ---------------- fakes ----------------
|
||||
|
||||
/// <summary>Listens to a single instrument by name on the Galaxy driver meter and sums the values.</summary>
|
||||
|
||||
@@ -281,6 +281,66 @@ public sealed class StatusCodeMapTests
|
||||
StatusCodeMap.FromMxStatus(s).ShouldBe(StatusCodeMap.Bad);
|
||||
}
|
||||
|
||||
// ===== #872 item 1 (owner decision 2026-11-13): Pending / Warning rows are Uncertain, never Bad =====
|
||||
// MXAccess sets success = -1 (VARIANT_TRUE) on a Pending row: accepted, in progress. A Warning is
|
||||
// degraded-but-usable. Neither is IsSuccess() (category == Ok), so both reach FromMxStatus, and both map to
|
||||
// Uncertain for ANY detail — ahead of the detail vocabulary, so a vocabulary detail cannot turn them Bad.
|
||||
|
||||
/// <summary>#872: a Pending or Warning row maps to Uncertain for detail 0 and for non-zero details,
|
||||
/// including details the vocabulary would otherwise map to a specific Bad code.</summary>
|
||||
/// <param name="category">Pending or Warning.</param>
|
||||
/// <param name="success">The raw success value (Pending carries -1 live).</param>
|
||||
/// <param name="detail">The MxStatusDetail code.</param>
|
||||
[Theory]
|
||||
[InlineData(MxStatusCategory.Pending, -1, 0)] // the live-captured shape (Suspend/Activate return)
|
||||
[InlineData(MxStatusCategory.Pending, -1, 1)] // MX_E_RequestTimedOut would be BadTimeout
|
||||
[InlineData(MxStatusCategory.Pending, 0, 1007)] // MX_E_NotWriteable would be BadNotWritable
|
||||
[InlineData(MxStatusCategory.Pending, -1, 8001)] // would be BadTypeMismatch
|
||||
[InlineData(MxStatusCategory.Pending, -1, 2001)] // unmapped detail
|
||||
[InlineData(MxStatusCategory.Warning, 0, 0)]
|
||||
[InlineData(MxStatusCategory.Warning, 1, 2)] // MX_E_PlatformCommunicationError would be BadCommunicationError
|
||||
[InlineData(MxStatusCategory.Warning, 0, 1004)] // MX_E_DataOutOfRange would be BadOutOfRange
|
||||
[InlineData(MxStatusCategory.Warning, 0, 2001)] // unmapped detail
|
||||
public void FromMxStatus_PendingOrWarning_AnyDetail_IsUncertain(MxStatusCategory category, int success, int detail)
|
||||
{
|
||||
var s = new MxStatusProxy { Success = success, Category = category, Detail = detail, RawDetectedBy = 0 };
|
||||
StatusCodeMap.FromMxStatus(s).ShouldBe(StatusCodeMap.Uncertain);
|
||||
}
|
||||
|
||||
/// <summary>#872: the once-per-(detail, category) warning is kept for Pending / Warning rows.</summary>
|
||||
[Fact]
|
||||
public void FromMxStatus_PendingRow_LogsOncePerDetailAndCategory()
|
||||
{
|
||||
var logger = new CapturingLogger();
|
||||
// Detail distinct from every other test so the process-wide once-set cannot already hold it.
|
||||
var s = new MxStatusProxy { Success = -1, Category = MxStatusCategory.Pending, Detail = 87201 };
|
||||
for (var i = 0; i < 5; i++) StatusCodeMap.FromMxStatus(s, logger).ShouldBe(StatusCodeMap.Uncertain);
|
||||
logger.Entries.Count.ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #872 live capture (windev 2026-11-13, mxaccessgw docs/LiveCaptures-2026-11-13.md §3): detail 8001 is
|
||||
/// the automation object's ConfigurationError for a write rejected on type conversion (a string written to
|
||||
/// a double). It maps to BadTypeMismatch, not the category's BadConfigurationError.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void FromMxStatus_Detail8001_AutomationObjectTypeConversion_IsTypeMismatch()
|
||||
{
|
||||
var s = new MxStatusProxy { Success = 0, Category = MxStatusCategory.ConfigurationError, Detail = 8001, RawDetectedBy = 5 };
|
||||
StatusCodeMap.FromMxStatus(s).ShouldBe(StatusCodeMap.BadTypeMismatch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #872 live capture: detail 8018 (SecurityError, a verified write naming the writer as verifier) stays
|
||||
/// BadUserAccessDenied via its category.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void FromMxStatus_Detail8018_VerifiedWriteSelfVerifier_IsUserAccessDenied()
|
||||
{
|
||||
var s = new MxStatusProxy { Success = 0, Category = MxStatusCategory.SecurityError, Detail = 8018, RawDetectedBy = 5 };
|
||||
StatusCodeMap.FromMxStatus(s).ShouldBe(StatusCodeMap.BadUserAccessDenied);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that top two bits of status codes follow OPC UA convention.</summary>
|
||||
[Fact]
|
||||
public void TopByteCategoryBits_StayWithinOpcUaConvention()
|
||||
|
||||
Reference in New Issue
Block a user