feat(diagnostics): VM emits trace events + CallScriptDispatches stat

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-07-07 15:21:28 -04:00
parent 87b23aabe4
commit b76e9d2c4f
6 changed files with 99 additions and 16 deletions

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Age.Engine.Diagnostics;
using Age.Engine.Hosting;
using Age.Engine.Model;
@@ -36,3 +38,14 @@ internal sealed class AnyProvider : IScriptProvider
public AnyProvider(Script s) => _s = s;
public Script? GetById(long id) => _s;
}
/// <summary>Captures every trace event for assertions; TracingSteps is settable so a test can
/// exercise the Step gate both ways.</summary>
internal sealed class RecordingTraceSink : ITraceSink
{
public bool TracingSteps { get; init; }
public readonly List<TraceEvent> Events = new();
public void Emit(in TraceEvent e) => Events.Add(e);
public List<long> CallScriptIds =>
Events.Where(e => e.Kind == TraceEventKind.CallScript).Select(e => e.Id).ToList();
}