«Aggiungi account» ha una sola casella: mentre Alberto scrive compaiono subito i suggerimenti locali, poi i profili di Instagram con la foto, come chiesto in #37. Il browser di Febe scrive nella casella «Cerca» di Instagram con tasti veri da una mappa chiusa (mai Invio, Tab o Esc), controlla prima il fuoco, legge la risposta della pagina e non clicca mai un risultato. La ricerca ha una categoria propria nel Governatore, con tetti larghi che non consumano quelli della raccolta, e si dà il turno con il motore sull'unica pagina; a fine sessione la pagina torna comunque al riposo. Le foto passano dal CDN con un permesso ciascuna e restano solo in memoria. Le risposte di Alberto del 15 novembre (controllo del fuoco, turni, evento requestWillBeSent, niente foto dei seguiti per ora) sono in §6.1 e in docs/decisioni.md. Su Instagram vero la ricerca parte quando i bersagli search-open e search-box saranno raccolti dal vivo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
147 lines
5.9 KiB
C#
147 lines
5.9 KiB
C#
using Febe.Core.Abstractions;
|
|
|
|
namespace Febe.Core.Domain;
|
|
|
|
/// <summary>An hourly and daily budget for one action category.</summary>
|
|
public sealed record Budget(int PerHour, int PerDay);
|
|
|
|
/// <summary>
|
|
/// Values of a caution profile (spec §7.5). These are cautious starting estimates, not official limits
|
|
/// and not measurements: the interface must say so.
|
|
/// </summary>
|
|
public sealed record CautionProfile
|
|
{
|
|
public required CautionProfileKind Kind { get; init; }
|
|
|
|
/// <summary>Start of the daily active window (local time).</summary>
|
|
public required TimeOnly WindowStart { get; init; }
|
|
|
|
/// <summary>End of the daily active window (local time); may be after midnight (e.g. 00:30).</summary>
|
|
public required TimeOnly WindowEnd { get; init; }
|
|
|
|
/// <summary>Random daily shift applied to start and end, ± this amount.</summary>
|
|
public required TimeSpan WindowJitter { get; init; }
|
|
|
|
public required TimeSpan SessionMin { get; init; }
|
|
public required TimeSpan SessionMax { get; init; }
|
|
public required TimeSpan PauseMin { get; init; }
|
|
public required TimeSpan PauseMax { get; init; }
|
|
|
|
/// <summary>Budgets per category, excluding <see cref="ActionKind.DataDownload"/>.</summary>
|
|
public required IReadOnlyDictionary<ActionKind, Budget> Budgets { get; init; }
|
|
|
|
/// <summary>Daily download budget in bytes.</summary>
|
|
public required long DataPerDayBytes { get; init; }
|
|
|
|
/// <summary>Default per-account backfill limit (posts per day).</summary>
|
|
public required int BackfillPostsPerAccountPerDay { get; init; }
|
|
|
|
/// <summary>Gradual start: days to go from half to full budgets.</summary>
|
|
public required int RampUpDays { get; init; }
|
|
|
|
/// <summary>Active weekdays (all by default).</summary>
|
|
public IReadOnlySet<DayOfWeek> ActiveDays { get; init; } = new HashSet<DayOfWeek>(Enum.GetValues<DayOfWeek>());
|
|
|
|
public bool GradualStart { get; init; } = true;
|
|
|
|
public GesturePace Pace { get; init; } = GesturePace.Natural;
|
|
|
|
private const long GB = 1024L * 1024 * 1024;
|
|
|
|
public static CautionProfile Prudent { get; } = new()
|
|
{
|
|
Kind = CautionProfileKind.Prudent,
|
|
WindowStart = new TimeOnly(7, 30),
|
|
WindowEnd = new TimeOnly(23, 30),
|
|
WindowJitter = TimeSpan.FromMinutes(40),
|
|
SessionMin = TimeSpan.FromMinutes(2),
|
|
SessionMax = TimeSpan.FromMinutes(10),
|
|
PauseMin = TimeSpan.FromMinutes(20),
|
|
PauseMax = TimeSpan.FromMinutes(90),
|
|
Budgets = new Dictionary<ActionKind, Budget>
|
|
{
|
|
[ActionKind.Home] = new(4, 30),
|
|
[ActionKind.ProfileOpen] = new(12, 100),
|
|
[ActionKind.StoryView] = new(50, 300),
|
|
[ActionKind.BackfillPage] = new(20, 100),
|
|
[ActionKind.SinglePost] = new(10, 60),
|
|
[ActionKind.FollowingListPage] = new(15, 60),
|
|
[ActionKind.ProfileSearch] = new(240, 1200),
|
|
},
|
|
DataPerDayBytes = 4 * GB,
|
|
BackfillPostsPerAccountPerDay = 300,
|
|
RampUpDays = 7,
|
|
};
|
|
|
|
public static CautionProfile Balanced { get; } = new()
|
|
{
|
|
Kind = CautionProfileKind.Balanced,
|
|
WindowStart = new TimeOnly(7, 0),
|
|
WindowEnd = new TimeOnly(0, 0),
|
|
WindowJitter = TimeSpan.FromMinutes(30),
|
|
SessionMin = TimeSpan.FromMinutes(3),
|
|
SessionMax = TimeSpan.FromMinutes(14),
|
|
PauseMin = TimeSpan.FromMinutes(12),
|
|
PauseMax = TimeSpan.FromMinutes(60),
|
|
Budgets = new Dictionary<ActionKind, Budget>
|
|
{
|
|
[ActionKind.Home] = new(5, 45),
|
|
[ActionKind.ProfileOpen] = new(20, 180),
|
|
[ActionKind.StoryView] = new(80, 500),
|
|
[ActionKind.BackfillPage] = new(30, 180),
|
|
[ActionKind.SinglePost] = new(15, 100),
|
|
[ActionKind.FollowingListPage] = new(20, 90),
|
|
[ActionKind.ProfileSearch] = new(300, 1500),
|
|
},
|
|
DataPerDayBytes = 8 * GB,
|
|
BackfillPostsPerAccountPerDay = 500,
|
|
RampUpDays = 5,
|
|
};
|
|
|
|
public static CautionProfile Fast { get; } = new()
|
|
{
|
|
Kind = CautionProfileKind.Fast,
|
|
WindowStart = new TimeOnly(6, 30),
|
|
WindowEnd = new TimeOnly(0, 30),
|
|
WindowJitter = TimeSpan.FromMinutes(30),
|
|
SessionMin = TimeSpan.FromMinutes(4),
|
|
SessionMax = TimeSpan.FromMinutes(18),
|
|
PauseMin = TimeSpan.FromMinutes(8),
|
|
PauseMax = TimeSpan.FromMinutes(40),
|
|
Budgets = new Dictionary<ActionKind, Budget>
|
|
{
|
|
[ActionKind.Home] = new(6, 60),
|
|
[ActionKind.ProfileOpen] = new(30, 300),
|
|
[ActionKind.StoryView] = new(120, 800),
|
|
[ActionKind.BackfillPage] = new(45, 300),
|
|
[ActionKind.SinglePost] = new(20, 160),
|
|
[ActionKind.FollowingListPage] = new(30, 150),
|
|
[ActionKind.ProfileSearch] = new(360, 1800),
|
|
},
|
|
DataPerDayBytes = 16 * GB,
|
|
BackfillPostsPerAccountPerDay = 800,
|
|
RampUpDays = 3,
|
|
};
|
|
|
|
public static CautionProfile For(CautionProfileKind kind) => kind switch
|
|
{
|
|
CautionProfileKind.Prudent => Prudent,
|
|
CautionProfileKind.Balanced => Balanced,
|
|
CautionProfileKind.Fast => Fast,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(kind), kind, "Custom profiles are stored values, not presets."),
|
|
};
|
|
|
|
/// <summary>Limits enforced by the interface (spec §7.5): minimum pause 5 min, session ≤ 30 min, window ≤ 20 h, no budget above twice «Rapido».</summary>
|
|
public static class Limits
|
|
{
|
|
public static readonly TimeSpan MinPause = TimeSpan.FromMinutes(5);
|
|
public static readonly TimeSpan MaxSession = TimeSpan.FromMinutes(30);
|
|
public static readonly TimeSpan MaxWindow = TimeSpan.FromHours(20);
|
|
|
|
public static Budget MaxBudget(ActionKind kind) =>
|
|
new(Fast.Budgets[kind].PerHour * 2, Fast.Budgets[kind].PerDay * 2);
|
|
|
|
public static long MaxDataPerDayBytes => Fast.DataPerDayBytes * 2;
|
|
}
|
|
}
|