fix: add truthful KTAP monitoring diagnostics

This commit is contained in:
2026-07-10 12:17:42 +09:00
parent fc932b27f6
commit 306d3a70a1
15 changed files with 764 additions and 33 deletions

View File

@@ -191,6 +191,13 @@ internal sealed record SafeTestCommandReport(
string Mode,
bool ConnectRequestIssued,
bool? ComActivationAttempted,
string LastKtapConnectState,
bool KtapConnectAttempted,
bool? KtapConnectAccepted,
bool? KtapHelloObserved,
bool? NetworkMonitoringRecordExpected,
bool NetworkMonitoringCheckRequired,
bool? NetworkMonitoringVerified,
bool Completed,
bool OutcomeUnknown,
bool OutputMayBeActive,
@@ -228,6 +235,8 @@ internal static class IsolatedTestCommandExecutor
var connectRequestIssued = false;
var connectResultReceived = false;
bool? comActivationAttempted = false;
var lastKtapConnectState = PlayoutKtapConnectState.NotAttempted;
bool? ktapHelloObserved = null;
var completed = false;
var outcomeUnknown = false;
string? stoppedAfter = null;
@@ -248,6 +257,7 @@ internal static class IsolatedTestCommandExecutor
connectRequestIssued = true;
var connect = await engine.ConnectAsync(cancellationToken).ConfigureAwait(false);
connectResultReceived = true;
CaptureKtapEvidence();
AddStep(steps, "command", connect);
comActivationAttempted = InferComActivationAttempt(connect.Code);
if (!connect.IsSuccess)
@@ -355,6 +365,7 @@ internal static class IsolatedTestCommandExecutor
{
if (engine is not null)
{
CaptureKtapEvidence();
if (outputMayBeActive && !takeOutAttempted && !outcomeUnknown)
{
takeOutAttempted = true;
@@ -420,6 +431,7 @@ internal static class IsolatedTestCommandExecutor
try
{
await engine.DisposeAsync().ConfigureAwait(false);
CaptureKtapEvidence();
adapterDisposed = true;
}
catch
@@ -457,6 +469,23 @@ internal static class IsolatedTestCommandExecutor
"Test",
connectRequestIssued,
comActivationAttempted,
ToWireValue(lastKtapConnectState),
lastKtapConnectState != PlayoutKtapConnectState.NotAttempted,
lastKtapConnectState switch
{
PlayoutKtapConnectState.AcceptedUnconfirmed => true,
PlayoutKtapConnectState.NotAttempted => false,
_ => null
},
ktapHelloObserved,
lastKtapConnectState switch
{
PlayoutKtapConnectState.AcceptedUnconfirmed => true,
PlayoutKtapConnectState.NotAttempted => false,
_ => null
},
lastKtapConnectState != PlayoutKtapConnectState.NotAttempted,
null,
completed,
outcomeUnknown,
outputMayBeActive,
@@ -468,8 +497,29 @@ internal static class IsolatedTestCommandExecutor
quarantineAttempted,
quarantineCompleted,
adapterDisposed));
void CaptureKtapEvidence()
{
if (engine is null)
{
return;
}
var status = engine.Status;
lastKtapConnectState = status.LastKtapConnectState;
ktapHelloObserved = status.KtapHelloObserved;
}
}
private static string ToWireValue(PlayoutKtapConnectState state) => state switch
{
PlayoutKtapConnectState.NotAttempted => "not-attempted",
PlayoutKtapConnectState.Attempted => "attempted",
PlayoutKtapConnectState.AcceptedUnconfirmed => "accepted-unconfirmed",
PlayoutKtapConnectState.Failed => "failed",
_ => "not-attempted"
};
private static void AddStep(
ICollection<SafeCommandStep> steps,
string phase,

View File

@@ -78,6 +78,13 @@ static int Probe()
architecture = Environment.Is64BitProcess ? "x64" : "x86",
connectRequestIssued = false,
comActivationAttempted = false,
lastKtapConnectState = "not-attempted",
ktapConnectAttempted = false,
ktapConnectAccepted = false,
ktapHelloObserved = (bool?)null,
networkMonitoringRecordExpected = false,
networkMonitoringCheckRequired = false,
networkMonitoringVerified = (bool?)null,
runtimeRegistration = new
{
ready = runtimeRegistration.IsReady,
@@ -123,8 +130,15 @@ static async Task<int> DryRunAsync()
command = "dry-run",
mode = engine.Status.Mode.ToString(),
state = engine.Status.State.ToString(),
connectRequestIssued = false,
connectRequestIssued = true,
comActivationAttempted = false,
lastKtapConnectState = "not-attempted",
ktapConnectAttempted = false,
ktapConnectAccepted = false,
ktapHelloObserved = (bool?)null,
networkMonitoringRecordExpected = false,
networkMonitoringCheckRequired = false,
networkMonitoringVerified = (bool?)null,
commands = results.Select(result => new
{
operation = result.Operation.ToString(),
@@ -149,6 +163,13 @@ static int TestPlan(SmokeCommandInvocation invocation)
runtimeProcessGateChecked = false,
connectRequestIssued = false,
comActivationAttempted = false,
lastKtapConnectState = "not-attempted",
ktapConnectAttempted = false,
ktapConnectAccepted = false,
ktapHelloObserved = (bool?)null,
networkMonitoringRecordExpected = false,
networkMonitoringCheckRequired = false,
networkMonitoringVerified = (bool?)null,
sceneCount = plan.PrepareCue is null ? 0 : 2,
automaticReconnectEnabled = plan.Options.ReconnectEnabled,
safety = "Configuration and scene assets validated only; no engine or COM was created."
@@ -209,6 +230,13 @@ static void WritePreflightFailure(string command, string errorCode) =>
runtimeProcessGateChecked = false,
connectRequestIssued = false,
comActivationAttempted = false,
lastKtapConnectState = "not-attempted",
ktapConnectAttempted = false,
ktapConnectAccepted = false,
ktapHelloObserved = (bool?)null,
networkMonitoringRecordExpected = false,
networkMonitoringCheckRequired = false,
networkMonitoringVerified = (bool?)null,
errorCode,
safety = "Rejected before engine creation; no COM activation was attempted."
});
@@ -227,6 +255,13 @@ static int Usage(string? errorCode)
command = "invalid",
connectRequestIssued = false,
comActivationAttempted = false,
lastKtapConnectState = "not-attempted",
ktapConnectAttempted = false,
ktapConnectAccepted = false,
ktapHelloObserved = (bool?)null,
networkMonitoringRecordExpected = false,
networkMonitoringCheckRequired = false,
networkMonitoringVerified = (bool?)null,
errorCode = errorCode ?? "invalid-command-line"
});
Console.Error.WriteLine(