Files
AutopilotMonitor/src/Backend/AutopilotMonitor.Functions.Tests/ScriptOutputReconciliationClassificationTests.cs
T
Oliver Kieselbach f392819b97 Portal, MCP and backend apply script_output_reconciliation: a corrected platform run shows its own output and "exit n/a" (D-316)
Web: the script panel applies the correction to the run its runId names: the saved output replaces the emitted one, a foreign end block's exit code shows as n/a with an explanation, the state follows the corrected data instead of the emitted event type, and the output carries a short "from IME's saved result" note. The timeline marks the original row as corrected later, and the correction event falls under the script-output setting like the other script events. The session page passes the event to the panel; the gather-rule event list knows the type.

MCP: get_session_summary no longer counts a script_failed as an error, ranks it as one or attaches the exit code's catalog text when a foreign correction with IME result Success names its run.

Backend: the correction never heals a stalled session and never counts as a script run.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-04 15:15:07 +02:00

53 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using AutopilotMonitor.Functions.Services;
using AutopilotMonitor.Shared;
using AutopilotMonitor.Shared.Models;
using Xunit;
namespace AutopilotMonitor.Functions.Tests;
/// <summary>
/// D-316: the agent corrects an already reported platform run from IME's saved result with a
/// script_output_reconciliation. It is observation of an earlier run: it never heals a Stalled session and never
/// counts as another script run.
/// </summary>
public class ScriptOutputReconciliationClassificationTests
{
private static readonly DateTime At = new(2026, 10, 3, 20, 59, 8, DateTimeKind.Utc);
[Fact]
public void A_correction_alone_is_no_real_activity_and_no_script_run()
{
var classification = EventIngestProcessor.ClassifyEvents(new List<EnrollmentEvent>
{
Event(Constants.EventTypes.ScriptOutputReconciliation, new Dictionary<string, object> { ["scriptType"] = "platform", ["runId"] = "run-1", ["outcome"] = "foreign" }),
});
Assert.False(classification.HasNonPeriodicRealEvent);
Assert.Equal(0, classification.PlatformScriptCount);
}
[Fact]
public void The_corrected_run_counts_once_as_a_platform_script()
{
var classification = EventIngestProcessor.ClassifyEvents(new List<EnrollmentEvent>
{
Event("script_failed", new Dictionary<string, object> { ["scriptType"] = "platform", ["runId"] = "run-1", ["exitCode"] = "1" }),
Event(Constants.EventTypes.ScriptOutputReconciliation, new Dictionary<string, object> { ["scriptType"] = "platform", ["runId"] = "run-1", ["outcome"] = "foreign" }),
});
Assert.True(classification.HasNonPeriodicRealEvent);
Assert.Equal(1, classification.PlatformScriptCount);
}
private static EnrollmentEvent Event(string eventType, Dictionary<string, object> data) => new()
{
EventId = Guid.NewGuid().ToString(),
Timestamp = At,
EventType = eventType,
Source = "RegistryScriptResult",
Data = data,
};
}