Collegamento e motore: correzioni regole-1, regole-2, regole-6, websec-1, websec-5, websec-6, engine-1, engine-2, sched-1

Pagine aperte da Alberto non sono segnali (regole-1); cookie perso fuori sessione = disconnessione (regole-2); pagina a riposo quando Alberto lascia il browser (regole-6); la lease di «Accedi»/«Usa il browser» finisce da sola dopo 2 minuti senza vista remota né finestra (websec-1); ping con scadenza sulla vista remota (websec-5); aperture della vista remota serializzate (websec-6); orologio virtuale senza fine anticipata (engine-1); la sincronizzazione della coda non duplica il compito in corso (engine-2); raccolte in evidenza programmate (sched-1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-14 00:21:13 +00:00
1 parent 78c92eb2a4
commit aff81dfac9
19 files changed
+1122 -92

No files matched your search

+19 -2
View File
@@ -31,6 +31,15 @@ public sealed class SignalDetector : IResponseObserver, IResponseConsumer, IStop
public TimeSpan DedupeWindow { get; }
/// <summary>
/// True while the page is Alberto's, not the engine's: he holds the «driving» lease and no session runs. The
/// addresses he opens then — the login page of «Accedi a Instagram», a verification he completes by hand — are not
/// engine actions (rule 7 of §2) nor the page «going back to the login» of §7.6, so path rules (navigations and
/// main documents) are not signals. Status and text rules, and the cookie check of the recipes, still are.
/// Null: the page is always the engine's.
/// </summary>
public Func<bool>? UserOwnsPage { get; init; }
/// <summary>Raised after a signal has been reported to the breaker.</summary>
public event EventHandler<Signal>? SignalRaised;
@@ -49,6 +58,7 @@ public sealed class SignalDetector : IResponseObserver, IResponseConsumer, IStop
{
ArgumentNullException.ThrowIfNull(response);
var scope = response.IsMainFrameDocument ? SignalScope.Document : SignalScope.Subresource;
var paths = !UserIsOnPage();
foreach (var rule in _rules.Rules)
{
if (!rule.HostKinds.Contains(response.HostKind) || (rule.Scope & scope) == 0)
@@ -57,7 +67,7 @@ public sealed class SignalDetector : IResponseObserver, IResponseConsumer, IStop
}
if ((rule.Statuses.Count > 0 && rule.Statuses.Contains(response.Status))
|| (rule.Path is not null && SafeIsMatch(rule.Path, response.Path)))
|| (paths && rule.Path is not null && SafeIsMatch(rule.Path, response.Path)))
{
return Raise(rule.Level, rule.Code, response.Url);
}
@@ -66,10 +76,15 @@ public sealed class SignalDetector : IResponseObserver, IResponseConsumer, IStop
return null;
}
/// <summary>Path rules on a main-frame navigation.</summary>
/// <summary>Path rules on a main-frame navigation (none while the page is Alberto's: <see cref="UserOwnsPage"/>).</summary>
public Signal? ObserveNavigation(NavigationDescriptor navigation)
{
ArgumentNullException.ThrowIfNull(navigation);
if (UserIsOnPage())
{
return null;
}
foreach (var rule in _rules.Rules)
{
if (rule.Path is null || (rule.Scope & SignalScope.Navigation) == 0 || !rule.HostKinds.Contains(navigation.HostKind))
@@ -144,6 +159,8 @@ public sealed class SignalDetector : IResponseObserver, IResponseConsumer, IStop
public Signal? ObserveSessionCookie(bool present) =>
present ? null : Raise(SignalLevel.Disconnect, SignalRules.SessionCookieMissingCode, null);
private bool UserIsOnPage() => UserOwnsPage?.Invoke() == true;
private Signal? Raise(SignalLevel level, string code, string? url)
{
var now = _clock.Now;