Instagram: Febe legge le risposte vere (campioni dal HAR del 21/10)
verifica / controlli (push) Successful in 2m10s
verifica / prove (push) Successful in 26m16s
verifica / installatore (push) Successful in 5m39s
verifica / immagine (push) Successful in 28m39s

Febe non estraeva nulla da Instagram per due motivi. Instagram manda i
dati di storie e raccolte (GraphQL) come text/javascript, e la cattura
leggeva solo le risposte dichiarate JSON: le scartava tutte. E i file di
Instagram (lettori, bersagli) erano scheletri, quindi le ricette si
rifiutavano di girare.

Alberto ha mandato un HAR del suo browser e una guida. La guida descrive
richieste costruite a mano, vietate dalle regole 2-4, e un formato che
nel HAR non compare: non si usa. Dal HAR si è letta solo la forma; le
risposte utili sono diventate campioni grezzi fuori dal repository,
ripuliti e verificati con febe-sonda (tests/Febe.Tests/campioni/instagram).

Che cosa cambia:
- la cattura legge le risposte text/javascript chieste dalla pagina (mai
  gli script) e ogni blocco JSON incorporato nel documento della pagina,
  e avvisa quando un corpo atteso non arriverà;
- le risposte che non parlano di contenuti (promozioni, «storia vista»)
  si ignorano invece di valere come formato non riconosciuto;
- lettori.instagram.json è confermato, con sole chiavi presenti nei
  campioni; identificativi delle raccolte nella forma dell'indirizzo;
- bersagli.instagram.json ha le pagine viste nel traffico vero; i
  bersagli restano vuoti (H11): storie, raccolte, Taggati e Reel
  aspettano lo script tools/bersagli/raccogli-bersagli.js;
- le ricette del profilo reggono dati in risposte diverse e prendono la
  paginazione solo dalla risposta che porta i loro post; l'elenco dei
  seguiti scarta i profili suggeriti; «Tu» si riconosce anche dal solo
  identificativo dell'account collegato;
- il visualizzatore delle raccolte conta i contenuti (l'indirizzo non
  cambia), chiede il permesso prima di ogni contenuto e si chiude sempre;
- una ricetta che la configurazione non lascia girare è «Da configurare»:
  non è un guasto, non si sospende, non si pianifica; le sospensioni
  dovute ai file vecchi si azzerano una volta al cambio dei file;
- la barra laterale dice «Collegato» dal cookie di sessione; i «Post
  singolo» per gli indirizzi scaduti non vengono più annullati;
- febe-sonda da-har; la ripulitura tiene latest_reel_media e mette un
  riempitivo neutro sotto le chiavi simili a segreti (gitleaks).

Prove su Windows: 783 superate, 76 saltate (Chromium e Xvfb, nella CI).
Nulla è stato provato contro Instagram. Dettagli e decisioni in
docs/stato.md e docs/decisioni.md (righe del 25 ottobre).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-25 14:22:16 +01:00
1 parent b3a7c31e5a
commit 31bbbf8bb7
69 files changed
+9184 -453

No files matched your search

@@ -50,11 +50,13 @@ public sealed record RecipeEnvironment
/// Common rules: the Governor is asked before every counted action and a refusal stops the recipe in order; a stop
/// signal stops it where it is and leaves the page as it is; a missing target stops it with a report, never with
/// coordinates; an unknown response shape stops it with <see cref="RecipeStatus.UnrecognizedFormat"/> and an event
/// that carries only the key structure. Recipes refuse to run on a site whose map or reader vocabulary is still a
/// skeleton (the first Instagram files, to be filled after M0).
/// that carries only the key structure. A recipe refuses to run, as <see cref="RecipeStatus.NotConfigured"/>, while the
/// site's map lacks a page or target it needs or the reader vocabulary is not usable (Instagram's targets, H11).
/// </remarks>
public sealed partial class RecipeRunner : IRecipeRunner
{
private readonly Lock _refusalsGate = new();
private readonly HashSet<RecipeKind> _refusalsReported = [];
private long? _sessionId;
private RecipeKind? _lastKind;
@@ -83,15 +85,19 @@ public sealed partial class RecipeRunner : IRecipeRunner
_ => kind.ToString(),
};
/// <summary>Pages and targets a recipe cannot work without.</summary>
/// <summary>
/// Pages and targets a recipe cannot work without. «profile-not-found» is not among them: it is looked up only when
/// the map sets it, and without it a profile that does not exist gives no data, judged like any page that arrives
/// empty.
/// </summary>
public static (IReadOnlyList<string> Pages, IReadOnlyList<string> Targets) Requirements(RecipeKind kind) => kind switch
{
RecipeKind.FollowingSweep => ([SitePages.Home], []),
RecipeKind.AccountStories => ([SitePages.Profile, SitePages.StoryViewer], [SiteTargets.ProfileStoryRing, SiteTargets.ViewerNext, SiteTargets.ViewerClose]),
RecipeKind.ProfileCheck or RecipeKind.Backfill => ([SitePages.Profile], [SiteTargets.ProfileNotFound]),
RecipeKind.ProfileCheck or RecipeKind.Backfill => ([SitePages.Profile], []),
RecipeKind.Highlight => ([SitePages.Profile, SitePages.HighlightViewer], [SiteTargets.ProfileHighlight, SiteTargets.ViewerNext, SiteTargets.ViewerClose]),
RecipeKind.Tagged => ([SitePages.Profile], [SiteTargets.ProfileNotFound, SiteTargets.ProfileTabTagged]),
RecipeKind.Reels => ([SitePages.Profile], [SiteTargets.ProfileNotFound, SiteTargets.ProfileTabReels]),
RecipeKind.Tagged => ([SitePages.Profile], [SiteTargets.ProfileTabTagged]),
RecipeKind.Reels => ([SitePages.Profile], [SiteTargets.ProfileTabReels]),
RecipeKind.SinglePost => ([SitePages.Post], []),
RecipeKind.FollowingList => ([SitePages.Following], []),
_ => ([], []),
@@ -112,20 +118,23 @@ public sealed partial class RecipeRunner : IRecipeRunner
ArgumentNullException.ThrowIfNull(session);
var name = Name(request.Kind);
var (pages, targets) = Requirements(request.Kind);
var missing = Env.SiteMap.Missing(pages, targets);
if (missing.Count > 0)
// A map or a vocabulary that lacks what the recipe needs is a state of the configuration, not a failure of the
// recipe: nothing is done, nothing counts towards suspension, and it is said once per recipe and process (the
// engine stops planning it, NotConfiguredReason).
if (Refusal(request.Kind) is { } refusal)
{
var message = $"«{name}» non può girare su {Env.SiteMap.Site}: la mappa dei bersagli non è ancora compilata (mancano {string.Join(", ", missing)}). Va completata con i campioni della sonda di M0 (ipotesi H11).";
await Writer.EventAsync("mappa-incompleta", message, EventSeverity.Error, null, session.SessionId, ct).ConfigureAwait(false);
return new RecipeOutcome(RecipeStatus.TargetNotFound, 0, 0, message);
}
bool first;
lock (_refusalsGate)
{
first = _refusalsReported.Add(request.Kind);
}
if (Env.Capture.Reader.Vocabulary.UnusableReason is { } unusable)
{
var message = $"«{name}» non può girare: {unusable}";
await Writer.EventAsync("lettori-incompleti", message, EventSeverity.Error, null, session.SessionId, ct).ConfigureAwait(false);
return new RecipeOutcome(RecipeStatus.UnrecognizedFormat, 0, 0, message);
if (first)
{
await Writer.EventAsync(refusal.Code, refusal.Message + SessionComposer.NotConfiguredTail, EventSeverity.Warning, null, session.SessionId, ct).ConfigureAwait(false);
}
return new RecipeOutcome(RecipeStatus.NotConfigured, 0, 0, refusal.Message);
}
if (Env.Breaker is { } breaker && !breaker.State.AllowsSiteActions)
@@ -206,6 +215,28 @@ public sealed partial class RecipeRunner : IRecipeRunner
};
}
/// <inheritdoc/>
public string? NotConfiguredReason(RecipeKind kind) => Refusal(kind)?.Message;
/// <summary>
/// Why the site's configuration does not let <paramref name="kind"/> run, with the code of its timeline line: pages
/// or targets missing from the map, or a reader vocabulary that cannot be relied on. Null when it can run.
/// </summary>
private (string Code, string Message)? Refusal(RecipeKind kind)
{
var name = Name(kind);
var (pages, targets) = Requirements(kind);
var missing = Env.SiteMap.Missing(pages, targets);
if (missing.Count > 0)
{
return ("mappa-incompleta", $"«{name}» non può girare su {Env.SiteMap.Site}: la mappa dei bersagli non è ancora compilata (mancano {string.Join(", ", missing)}).");
}
return Env.Capture.Reader.Vocabulary.UnusableReason is { } unusable
? ("lettori-incompleti", $"«{name}» non può girare: {unusable}")
: null;
}
/// <summary>
/// The rest page (spec §6.1). After a verification request or a disconnection the page is left as it is, so that
/// Alberto sees what happened (spec §7.6): resting is skipped while the breaker says so.