// MUST be first: sets DATABASE_URL before db_client is evaluated. import "./setup_env"; import { test, expect, describe } from "bun:test"; import { isPermanentReportError } from "../src/readable_retry"; describe("readable-report retry: transient vs permanent", () => { test("a node that is down is transient — that is what the sweep is FOR", () => { expect(isPermanentReportError("node unreachable: Unable to connect. Is the computer able to access the url?")).toBe(false); expect(isPermanentReportError("node unreachable: The operation timed out.")).toBe(false); expect(isPermanentReportError("502 Bad Gateway")).toBe(false); // The model returned nothing. Worth another pass on a different draw. expect(isPermanentReportError("empty readable report")).toBe(false); }); test("a missing report file is permanent — only a new round can change it", () => { // e6613407 burned 13 node round-trips over three hours on this one. expect(isPermanentReportError("no fix report")).toBe(true); expect(isPermanentReportError("no impl report")).toBe(true); expect(isPermanentReportError("task not found")).toBe(true); expect(isPermanentReportError("feature not found")).toBe(true); // 验证线:没采到报告就挂掉的轮次(鉴权 / API 错误 / 一页没采到)会进 verify_failed 并触发 // 一次生成;认不出这两句,48 小时内每次扫描都会回去要一份永远不会出现的报告。 expect(isPermanentReportError("no verification report")).toBe(true); expect(isPermanentReportError("verification not found")).toBe(true); }); test("absent / blank errors are not permanent", () => { expect(isPermanentReportError(null)).toBe(false); expect(isPermanentReportError(undefined)).toBe(false); expect(isPermanentReportError(" ")).toBe(false); }); test("anchored: a longer message that merely mentions the phrase is not permanent", () => { // The satellite's 404 body is exactly "no fix report". Anything wrapping it // came from somewhere else and has not earned the same conclusion. expect(isPermanentReportError("generation aborted: no fix report yet, node still writing")).toBe(false); }); test("代答节点说的「没有报告」不算数 —— 它盘上本来就没有这个 workspace", () => { // 859e2594 的形状:home node 因为心跳被饿死而暂时 offline,请求被派给同平台的 // 另一台机器,它理直气壮回了 404。那句话对「报告存不存在」毫无信息量,判成永久 // 就等于把一份源文完好的报告永久放弃。标注出处正是为了让它匹配不上。 expect(isPermanentReportError("no impl report(代答节点 evaluator-android-01.shiro0.icu,非 home node)")).toBe(false); expect(isPermanentReportError("no fix report(代答节点 lemon-android-01.shiro0.icu,非 home node)")).toBe(false); }); });