Rapporto di diagnostica della raccolta (#39)
verifica / controlli (push) Successful in 18s
verifica / prove (push) Successful in 13m5s
verifica / installatore (push) Successful in 4m11s
verifica / immagine (push) Successful in 14m4s

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:
Alby96andClaude Opus 5.5 committed 2026-11-13 14:41:34 +01:00
1 parent bf03cb45a5
commit badd1681a0
55 files changed
+5395 -134

No files matched your search

+39 -1
View File
@@ -2,9 +2,11 @@ using System.Globalization;
using System.Text.Json;
using Febe.Core.Abstractions;
using Febe.Core.Alerts;
using Febe.Core.Collection.Diagnostics;
using Febe.Core.Domain;
using Febe.Core.Engine;
using Febe.Core.Storage;
using Febe.Web.Demo;
using Febe.Web.Engine;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
@@ -14,13 +16,20 @@ namespace Febe.Web.Api;
/// <summary>
/// What the Attività page needs beside the engine snapshot (spec §7.6, §7.9, mockups 06 and 11): the history of the
/// stops, the still frame of the browser, the probable duplicates waiting for Alberto.
/// stops, the still frame of the browser, the probable duplicates waiting for Alberto, the diagnostic report.
/// </summary>
public static class ActivityApi
{
/// <summary>Days of stops shown by the page.</summary>
public const int HistoryDays = 14;
/// <summary>
/// «Esporta il rapporto di diagnostica» (issue #39, spec §7.9): the traces of the engine sessions of the last two
/// weeks as a JSON file to send, with no data value in it. Also answered with a configuration problem, where the
/// engine never started and the report is empty.
/// </summary>
public const string DiagnosticsPath = "/api/engine/diagnostica";
public static void Map(IEndpointRouteBuilder endpoints)
{
endpoints.MapGet("/api/engine/incidents", async (IIncidentHistory history, IClock clock, CancellationToken ct) =>
@@ -56,8 +65,37 @@ public static class ActivityApi
var import = await storage.Duplicates.CountPendingAsync(DuplicateOrigin.Import, ct).ConfigureAwait(false);
return ApiHttp.Json(new DuplicateCountsDto(download, import), FebeJsonContext.Default.DuplicateCountsDto);
});
endpoints.MapGet(DiagnosticsPath, async (HttpContext context, IDiagnosticSource source, FebeWebOptions options, IClock clock, CancellationToken ct) =>
{
var gathered = await source.GatherAsync(ct).ConfigureAwait(false);
var now = clock.Now;
var zone = clock.LocalZone;
var edition = options.Demo ? DemoRequest.Edition(context) ?? FebeEdition.Desktop : options.Edition;
// Written whole before answering: a failure becomes an error message, never half a file.
using var buffer = new MemoryStream();
DiagnosticReport.Write(
buffer,
gathered.Traces,
new DiagnosticReportHeader(
options.Version,
EditionName(edition),
now,
zone,
DamagedLines: gathered.DamagedLines,
RecorderFaults: gathered.RecorderFaults,
UnreadableFiles: gathered.UnreadableFiles,
UnfinishedSessions: gathered.UnfinishedSessions));
context.Response.Headers.ContentDisposition = $"attachment; filename=\"{DiagnosticReport.FileName(now, zone)}\"";
context.Response.Headers.CacheControl = "no-store";
return Results.Bytes(buffer.ToArray(), "application/json; charset=utf-8");
});
}
/// <summary>The «edizione» of the diagnostic report.</summary>
public static string EditionName(FebeEdition edition) => edition == FebeEdition.Desktop ? "windows" : "docker";
public static async Task<IncidentListDto> IncidentsAsync(IIncidentHistory history, IClock clock, CancellationToken ct)
{
ArgumentNullException.ThrowIfNull(history);