feat(refresh): --assume-robots-on-403, for a host that hides only its robots.txt

Fandom answers our fetcher 403 on /robots.txt itself, from every address we
have, while api.php?action=parse answers the same User-Agent with a 200. The
gate fails closed on the unreadable file, so r1999, fgo, nikke and nikki can
never refresh — even though their rules are not unknown: a person read them in
a browser and wrote them into AGENTS.md, verbatim, which is how three of those
four were cleared in the first place.

This flag is that recorded permission, and nothing wider. What it deliberately
does not do is most of the design:

  - 403 only. A 401, a 5xx, a timeout or a soft 404 still mean we do not know
    what the site permits, and unknown is still not permission.
  - It never overrides a robots.txt we could read. A file that answers and
    disallows us is an answer, and it still wins. So this is no use for game8.co
    — whose robots.txt reads fine and welcomes us while its edge refuses the
    pages — and it must not become one.
  - Refused under CI. It stands in for a human having read a file this morning,
    and there is no human on a runner. A scheduled job asserting a permission
    nobody re-checked is exactly how "temporary" stops being temporary.
  - Loud. Every host it applied to is warned about by name, in the run log and
    in the summary, with a line saying to go re-read the file. An override that
    reports nothing is one nobody withdraws.

Nothing else about being a guest relaxes: one request per source, six hours
apart, spaced per host, conditional headers, no retries.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Lucas Winther
2026-08-19 04:45:54 +02:00
co-authored by Claude Opus 5
parent 239e970471
commit f67118913a
6 changed files with 259 additions and 6 deletions
+34
View File
@@ -263,6 +263,34 @@ describe("robots", () => {
expect(summary.warnings).toHaveLength(1);
});
test("fetching on an assumed robots permission is named in the summary", async () => {
// The override cannot be silent: a permission nobody can re-read is one
// nobody withdraws, so every host it applied to is reported by name and
// warned about, on a run that otherwise looks completely ordinary.
const { opts } = options({
robots: {
allows: async () => ({
allowed: true,
reason: "robots.txt returned 403; proceeding on a recorded permission",
assumedOnForbidden: true,
}),
},
});
const summary = await runRefresh(opts);
expect(summary.outcomes[0]?.result).toBe("fetched");
expect(summary.assumedRobots).toEqual(["game8.co"]);
expect(summary.warnings.some((w) => w.includes("--assume-robots-on-403"))).toBe(
true,
);
});
test("an ordinary run reports no assumed hosts at all", async () => {
const { opts } = options({});
const summary = await runRefresh(opts);
expect(summary.assumedRobots).toEqual([]);
});
test("one source blocked is a warning; all of them is a failure", async () => {
const blocked = {
allows: async (url: string) => ({
@@ -769,6 +797,7 @@ describe("what the runner reports to the runner", () => {
},
],
hardFailure: null,
assumedRobots: [],
};
test("a broken source becomes an annotation on the run page", () => {
@@ -928,6 +957,11 @@ describe("flags", () => {
});
});
test("parseArgs reads --assume-robots-on-403, and it is off by default", () => {
expect(parseArgs([]).assumeRobotsOn403).toBe(false);
expect(parseArgs(["--assume-robots-on-403"]).assumeRobotsOn403).toBe(true);
});
test("parseArgs rejects an unknown flag rather than ignoring it", () => {
expect(() => parseArgs(["--force"])).toThrow("unknown flag");
});