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

@@ -34,11 +34,46 @@ public sealed class CollectionUnitTests
}
[TestMethod]
public void TheInstagramMapIsASkeletonWithEveryEntryEmpty()
public void TheInstagramMapHasThePagesSeenInRealTrafficAndNoTargetYet()
{
var map = SiteMap.LoadInstagram();
Assert.AreEqual("instagram", map.Site);
Assert.AreEqual(SitePages.All.Count + SiteTargets.All.Count, map.Missing(SitePages.All, SiteTargets.All).Count, "Nothing is filled in before M0.");
// Pages: only those with evidence in the HAR of 21 October 2026 (Instagram's own route templates and the
// Referer of the page's requests). The others have none and stay empty.
string[] filled = [SitePages.Home, SitePages.Profile, SitePages.Post, SitePages.StoryViewer, SitePages.HighlightViewer];
string[] empty = [SitePages.ProfileFrom, SitePages.ReelsFrom, SitePages.TaggedFrom, SitePages.Following, SitePages.FollowingFrom];
CollectionAssert.AreEquivalent(SitePages.All.ToArray(), filled.Concat(empty).ToArray(), "Every page is decided.");
Assert.IsTrue(filled.All(map.HasPage));
CollectionAssert.AreEquivalent(empty.Select(p => $"pagina «{p}»").ToArray(), map.Missing(SitePages.All, []).ToArray());
Assert.AreEqual("/", map.BuildPath(SitePages.Home));
Assert.AreEqual("/mario.rossi/", map.BuildPath(SitePages.Profile, new Dictionary<string, string> { ["username"] = "mario.rossi" }));
Assert.AreEqual("/p/Abc_12-xYz9/", map.BuildPath(SitePages.Post, new Dictionary<string, string> { ["code"] = "Abc_12-xYz9" }));
Assert.IsNotNull(map.Match(SitePages.Home, "/"));
Assert.IsNull(map.Match(SitePages.Home, "/mario.rossi/"));
Assert.AreEqual("mario.rossi", map.Match(SitePages.Profile, "/mario.rossi/")!["username"]);
// Viewers: matched only, never opened. The story viewer carries the account and the story shown.
var story = map.Match(SitePages.StoryViewer, "/stories/mario/3456789012345678901/");
Assert.AreEqual("mario", story!["username"]);
Assert.AreEqual("3456789012345678901", story["id"]);
Assert.IsNull(map.Match(SitePages.StoryViewer, "/stories/mario/"), "Without the story id the shape does not match (to be confirmed live).");
Assert.IsNull(map.Match(SitePages.HighlightViewer, "/stories/mario/3456789012345678901/"));
// The highlight viewer: the 17 digits of the collection and no item id (the address stays the same while watching).
var highlight = map.Match(SitePages.HighlightViewer, "/stories/highlights/17841400000000000/");
CollectionAssert.AreEquivalent(new[] { "highlight" }, highlight!.Keys.ToArray());
Assert.AreEqual("17841400000000000", highlight["highlight"]);
// Overlap: a highlight address also has the story viewer's shape, with «highlights» as user name. The story
// recipe then sees «another account» and closes; the highlight recipe reads only its own page.
Assert.AreEqual("highlights", map.Match(SitePages.StoryViewer, "/stories/highlights/17841400000000000/")!["username"]);
// Targets: none has evidence yet (the HAR had no documents and no element attributes).
var missingTargets = map.Missing([], SiteTargets.All);
Assert.AreEqual(SiteTargets.All.Count, missingTargets.Count);
Assert.IsTrue(missingTargets.All(m => m.EndsWith("(vuoto)", StringComparison.Ordinal)), "Every target is listed, still empty.");
// The browser layer reads the same file: every target is a placeholder and is never looked up in the page.
var targets = TargetMap.LoadEmbedded("bersagli.instagram.json");
@@ -49,47 +84,77 @@ public sealed class CollectionUnitTests
Assert.AreEqual(TargetStatus.NotConfigured, lookup.Status);
Assert.AreEqual(0, cdp.Sent.Count, "A placeholder never reaches the page.");
StringAssert.Contains(lookup.Message, "H11");
// The copy next to the executable is the same map.
var copy = SiteMap.Load(Path.Combine(AppContext.BaseDirectory, "config", "bersagli.instagram.json"));
CollectionAssert.AreEquivalent(map.Missing(SitePages.All, SiteTargets.All).ToArray(), copy.Missing(SitePages.All, SiteTargets.All).ToArray());
}
[TestMethod]
public async Task RecipesRefuseToRunOnInstagramWhileTheMapOrTheReadersAreSkeletons()
public async Task OnInstagramOnlyRecipesThatNeedNoTargetGetPastTheMap()
{
using var temp = new TempFolder("ricette");
await using var db = await TestDatabase.OpenAsync(temp);
var clock = new VirtualClock();
var governor = new PermissiveGovernor();
var session = new TestSession((await db.Sessions.StartAsync(clock.Now)).Id);
RecipeEnvironment Environment(SiteMap map, ReaderVocabulary vocabulary) => new()
// The Instagram vocabulary is confirmed on real samples. To see which recipes get past the map without letting
// any of them reach the page, the runs use a copy marked as a hypothesis: the readers' gate comes right after
// the map's and stops them there.
Assert.IsTrue(ReaderVocabulary.LoadInstagram().IsUsable, ReaderVocabulary.LoadInstagram().UnusableReason);
var stopper = ReaderVocabulary.LoadInstagram() with { Status = VocabularyStatus.Hypothesis };
Task<RecipeOutcome> RunAsync(RecipeKind kind) => new RecipeRunner(new RecipeEnvironment
{
Driver = new UntouchableDriver(),
Capture = new CaptureCollector(new ShapeReader(vocabulary), clock),
Capture = new CaptureCollector(new ShapeReader(stopper), clock),
Governor = governor,
Signals = new SignalDetector(SignalRules.LoadDefault(), new RecordingBreaker(), clock),
Storage = db,
SiteMap = map,
SiteMap = SiteMap.LoadInstagram(),
Clock = clock,
Random = new SeededRandom(1),
};
}).RunAsync(new RecipeRequest(kind, 1), session, CancellationToken.None);
foreach (var kind in Enum.GetValues<RecipeKind>().Where(k => k != RecipeKind.FollowingSweep))
static void Refused(RecipeKind kind, RecipeOutcome outcome, string missing)
{
var outcome = await new RecipeRunner(Environment(SiteMap.LoadInstagram(), ReaderVocabulary.LoadTestSite()))
.RunAsync(new RecipeRequest(kind, 1), session, CancellationToken.None);
Assert.AreEqual(RecipeStatus.TargetNotFound, outcome.Status, kind.ToString());
Assert.AreEqual(RecipeStatus.NotConfigured, outcome.Status, kind.ToString());
StringAssert.Contains(outcome.Message, "mappa dei bersagli non è ancora compilata");
StringAssert.Contains(outcome.Message, missing, kind.ToString());
}
var sweep = await new RecipeRunner(Environment(SiteMap.LoadInstagram(), ReaderVocabulary.LoadTestSite()))
.RunAsync(new RecipeRequest(RecipeKind.FollowingSweep), session, CancellationToken.None);
StringAssert.Contains(sweep.Message, "pagina «home»");
static void Passed(RecipeKind kind, RecipeOutcome outcome)
{
Assert.AreEqual(RecipeStatus.NotConfigured, outcome.Status, $"{kind}: {outcome.Message}");
StringAssert.Contains(outcome.Message, "ipotesi", kind.ToString());
}
var readers = await new RecipeRunner(Environment(SiteMap.LoadTestSite(), ReaderVocabulary.LoadInstagram()))
.RunAsync(new RecipeRequest(RecipeKind.FollowingSweep), session, CancellationToken.None);
Assert.AreEqual(RecipeStatus.UnrecognizedFormat, readers.Status);
StringAssert.Contains(readers.Message, "ipotesi");
// Recipes that click something: every target is still empty (H11), while their pages are all there.
foreach (var kind in new[] { RecipeKind.AccountStories, RecipeKind.Highlight, RecipeKind.Tagged, RecipeKind.Reels })
{
var outcome = await RunAsync(kind);
Refused(kind, outcome, "(vuoto)");
Assert.IsFalse(outcome.Message!.Contains("pagina «", StringComparison.Ordinal), $"{kind}: {outcome.Message}");
}
// Recipes that only open pages.
Passed(RecipeKind.FollowingSweep, await RunAsync(RecipeKind.FollowingSweep));
Passed(RecipeKind.SinglePost, await RunAsync(RecipeKind.SinglePost));
// The profile check and the backfill need no target: the «not found» marker is looked up only when configured.
foreach (var kind in new[] { RecipeKind.ProfileCheck, RecipeKind.Backfill })
{
Assert.IsFalse(RecipeRunner.Requirements(kind).Targets.Contains(SiteTargets.ProfileNotFound), kind.ToString());
Passed(kind, await RunAsync(kind));
}
// No evidence of the address of the following list.
Refused(RecipeKind.FollowingList, await RunAsync(RecipeKind.FollowingList), $"pagina «{SitePages.Following}»");
Assert.AreEqual(0, governor.Requests.Count, "No permit asked, no gesture, no page.");
Assert.IsTrue((await db.Events.ListAsync(new EventQuery())).Any(e => e.Code == "mappa-incompleta"));
var events = await db.Events.ListAsync(new EventQuery());
Assert.IsTrue(events.Any(e => e.Code == "mappa-incompleta"));
Assert.IsTrue(events.Any(e => e.Code == "lettori-incompleti"));
}
[TestMethod]