Rapporto di diagnostica della raccolta (#39)
Dopo una prova dal vivo andata male, Alberto deve poter mandare un solo file che spieghi perché, senza che nessuno veda dati di altre persone. Attività ha ora il pulsante «Diagnostica», che scarica il rapporto delle sessioni degli ultimi 14 giorni: pagine aperte e forma degli indirizzi, risposte per tipo, stato e dimensione con ciò che i lettori ne hanno fatto, struttura stretta delle forme sconosciute, ricette, segnali, permessi negati, file in coda e scaricati, e il motivo di ogni arresto. Nel rapporto entrano solo valori da elenchi chiusi, numeri, orari e forme: mai nomi, indirizzi completi, codici, cursori, cookie o pezzi di risposte. Le forme degli indirizzi e la regola delle chiavi-dato passano dalla sonda a Core, e la sonda le richiama. Il registratore non lancia mai eccezioni verso la raccolta e tiene i file in Dati/diagnostica per 14 giorni. Prova che il rapporto non contiene valori, con controlli di mutazione; tre giri di revisione avversaria (25 difetti confermati, tutti corretti). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf03cb45a5
commit
badd1681a0
55 files changed
+5395
-134
No files matched your search
@@ -627,12 +627,15 @@ public sealed class EngineHost : IAsyncDisposable
|
||||
}
|
||||
|
||||
s.Runtime.CurrentSession = context;
|
||||
s.Diagnostics?.SessionStarted(record.Id, start, mood);
|
||||
s.Runtime.HadSessionSinceStart = true;
|
||||
Volatile.Write(ref _manualWaiting, false);
|
||||
s.Runtime.NextSessionAt = null;
|
||||
s.Events.Publish(EngineNotificationKind.StateChanged);
|
||||
|
||||
var outcome = SessionOutcome.Completed;
|
||||
var cause = SessionStopCause.WorkDone;
|
||||
SessionSummary? summary = null;
|
||||
var interrupted = false;
|
||||
try
|
||||
{
|
||||
@@ -642,25 +645,37 @@ public sealed class EngineHost : IAsyncDisposable
|
||||
sessionCts.Cancel();
|
||||
}
|
||||
|
||||
var summary = await _composer.RunAsync(context, outsideWindowTask, sessionCts.Token).ConfigureAwait(false);
|
||||
summary = await _composer.RunAsync(context, outsideWindowTask, sessionCts.Token).ConfigureAwait(false);
|
||||
if (summary.StoppedEarly || !s.Breaker.State.AllowsSiteActions || s.Runtime.IsPaused || s.Runtime.UserIsDriving)
|
||||
{
|
||||
outcome = StopOutcome();
|
||||
cause = ct.IsCancellationRequested ? SessionStopCause.Shutdown : StopCause(summary);
|
||||
}
|
||||
else
|
||||
{
|
||||
// A shutdown between two recipes leaves the composer as if its work were done: say what it was.
|
||||
cause = ct.IsCancellationRequested ? SessionStopCause.Shutdown
|
||||
: s.Clock.Now >= plannedEnd ? SessionStopCause.PlannedEnd
|
||||
: summary.BudgetsExhausted ? SessionStopCause.BudgetsExhausted
|
||||
: SessionStopCause.WorkDone;
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) when (!ct.IsCancellationRequested)
|
||||
{
|
||||
outcome = StopOutcome();
|
||||
cause = StopCause(null);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
outcome = SessionOutcome.Interrupted;
|
||||
cause = SessionStopCause.Shutdown;
|
||||
interrupted = true;
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
outcome = SessionOutcome.Failed;
|
||||
cause = SessionStopCause.Failed;
|
||||
await s.Events.WriteAsync(
|
||||
EventSeverity.Error,
|
||||
EngineEventCodes.RecipeFailed,
|
||||
@@ -677,10 +692,29 @@ public sealed class EngineHost : IAsyncDisposable
|
||||
|
||||
s.Runtime.CurrentSession = null;
|
||||
s.Runtime.Activity = null;
|
||||
await EndSessionAsync(record, context, outcome, outsideWindowTask, interrupted).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await EndSessionAsync(record, context, outcome, outsideWindowTask, interrupted).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
s.Diagnostics?.SessionEnded(record.Id, s.Clock.Now, outcome, cause, summary?.StoppedEarlyBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Why a session that did not reach its natural end stopped (diagnostic report): an open breaker first, then the
|
||||
/// pause, then Alberto at the browser, then a recipe outcome; anything else is a cancellation. A shutdown of Febe
|
||||
/// (the loop's token cancelled) is checked by the caller first: a real recipe returns «Cancelled» instead of throwing.
|
||||
/// </summary>
|
||||
private SessionStopCause StopCause(SessionSummary? summary) =>
|
||||
!_s.Breaker.State.AllowsSiteActions ? SessionStopCause.BreakerOpen
|
||||
: _s.Runtime.IsPaused ? SessionStopCause.Paused
|
||||
: _s.Runtime.UserIsDriving ? SessionStopCause.UserDriving
|
||||
: summary?.StoppedEarly == true ? SessionStopCause.StoppedEarly
|
||||
: SessionStopCause.Cancelled;
|
||||
|
||||
private async Task EndSessionAsync(SessionRecord record, SessionContext context, SessionOutcome outcome, EngineTask? outsideWindowTask, bool interrupted)
|
||||
{
|
||||
var s = _s;
|
||||
@@ -844,6 +878,10 @@ public sealed class EngineHost : IAsyncDisposable
|
||||
|
||||
private void OnBreakerChanged(object? sender, BreakerState state)
|
||||
{
|
||||
// The diagnostic report records the signal that stopped the breaker, also one the detector never saw (the
|
||||
// session cookie lost, reported by the connection): a logout must not look like any other stop.
|
||||
_s.Diagnostics?.BreakerChanged(state);
|
||||
|
||||
// Signals arrive on capture threads: the engine is never run inline on them (it may need the browser to answer).
|
||||
// The composer also checks the breaker before every recipe, so the session stops at once either way.
|
||||
CancellationTokenSource? session = null;
|
||||
|
||||
Reference in new issue
Block a user