Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/helpers/d1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function createTestEnv(overrides: Partial<Env> = {}): Env {
},
} as unknown as Queue,
GITHUB_APP_ID: "3824093",
GITHUB_APP_SLUG: "gittensory",
GITHUB_APP_SLUG: "loopover-orb",
GITTENSOR_UPSTREAM_REPO: "entrius/gittensor",
GITTENSOR_UPSTREAM_REF: "test",
GITTENSOR_REGISTRY_URL: "https://github.com/ghraw/entrius/gittensor/test/gittensor/validator/weights/master_repositories.json",
Expand Down
35 changes: 19 additions & 16 deletions test/unit/backfill-2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,9 @@ describe("GitHub backfill", () => {
{ name: "test", status: "completed", conclusion: "success" },
// BOTH bot-posted checks, still in_progress (posted but not yet concluded). Counting EITHER would
// defer the very review that concludes it — the self-deadlock that froze green-CI PRs as "CI pending".
{ name: "LoopOver Orb Review Agent", status: "in_progress", conclusion: null, app: { slug: "gittensory" } },
{ name: "Gittensory Gate", status: "in_progress", conclusion: null, app: { slug: "gittensory" } },
{ name: "LoopOver Context", status: "in_progress", conclusion: null, app: { slug: "gittensory" } },
{ name: "LoopOver Orb Review Agent", status: "in_progress", conclusion: null, app: { slug: "loopover-orb" } },
{ name: "Gittensory Gate", status: "in_progress", conclusion: null, app: { slug: "loopover-orb" } },
{ name: "LoopOver Context", status: "in_progress", conclusion: null, app: { slug: "loopover-orb" } },
],
});
}
Expand Down Expand Up @@ -721,7 +721,7 @@ describe("GitHub backfill", () => {
const url = input.toString();
if (url.includes("/check-runs?")) {
return Response.json({
check_runs: [{ name: "LoopOver Orb Review Agent", status: "completed", conclusion: "failure", output: { title: "Real gate failure" }, app: { slug: "gittensory" } }],
check_runs: [{ name: "LoopOver Orb Review Agent", status: "completed", conclusion: "failure", output: { title: "Real gate failure" }, app: { slug: "loopover-orb" } }],
});
}
if (url.includes("/status?")) return Response.json({ statuses: [] });
Expand Down Expand Up @@ -786,7 +786,7 @@ describe("GitHub backfill", () => {
return Response.json({
check_runs: [
{ name: "validate", status: "completed", conclusion: "success", app: { slug: "github-actions" } },
{ name: "LoopOver Orb Review Agent", status: "in_progress", conclusion: null, app: { slug: "gittensory" } },
{ name: "LoopOver Orb Review Agent", status: "in_progress", conclusion: null, app: { slug: "loopover-orb" } },
],
});
}
Expand Down Expand Up @@ -2005,7 +2005,7 @@ describe("GitHub backfill", () => {
{
body: "Own bot requested change",
url: "https://github.example/thread/own-member",
author: { login: "gittensory-orb[bot]" },
author: { login: "loopover-orb[bot]" },
authorAssociation: "MEMBER",
},
],
Expand Down Expand Up @@ -2157,8 +2157,8 @@ describe("GitHub backfill", () => {
nodes: [
{ isResolved: true, isOutdated: false, path: "a.ts", line: 1, comments: { nodes: [{ body: "resolved", author: { login: "superagent-security[bot]" } }] } },
{ isResolved: false, isOutdated: true, path: "b.ts", line: 2, comments: { nodes: [{ body: "outdated", author: { login: "superagent-security[bot]" } }] } },
{ isResolved: false, isOutdated: false, path: "c.ts", line: 3, comments: { nodes: [{ body: "own bot", author: { login: "gittensory-orb[bot]" }, authorAssociation: "OWNER" }] } },
{ isResolved: false, isOutdated: false, path: "own-collaborator.ts", line: 5, comments: { nodes: [{ body: "own bot with collaborator association", author: { login: "gittensory[bot]" }, authorAssociation: "COLLABORATOR" }] } },
{ isResolved: false, isOutdated: false, path: "c.ts", line: 3, comments: { nodes: [{ body: "own bot", author: { login: "loopover-orb[bot]" }, authorAssociation: "OWNER" }] } },
{ isResolved: false, isOutdated: false, path: "own-collaborator.ts", line: 5, comments: { nodes: [{ body: "own bot with collaborator association", author: { login: "loopover-orb[bot]" }, authorAssociation: "COLLABORATOR" }] } },
{ isResolved: false, isOutdated: false, path: "no-comments.ts", line: 6, comments: null },
{ isResolved: false, isOutdated: false, path: "d.ts", line: 4, comments: { nodes: [{ body: " ", author: { login: "superagent-security[bot]" } }, null] } },
null,
Expand Down Expand Up @@ -2652,18 +2652,21 @@ describe("GitHub backfill", () => {
});

describe("isOwnReviewThreadAuthor", () => {
const env = createTestEnv(); // GITHUB_APP_SLUG defaults to "gittensory" (test/helpers/d1.ts)
// Explicit bare slug -- NOT the shared "loopover-orb" createTestEnv() default (test/helpers/d1.ts) -- so
// this prefix-match test can exercise multiple realistic suffix forms below without a double "-orb-orb"
// suffix artifact.
const env = createTestEnv({ GITHUB_APP_SLUG: "loopover" });

it("matches our own gittensory app bot logins by prefix", () => {
for (const login of ["gittensory[bot]", "gittensory-orb[bot]", "gittensory-review[bot]", "GITTENSORY[bot]", "gittensory", "gittensory-orb"]) {
it("matches our own loopover app bot logins by prefix", () => {
for (const login of ["loopover[bot]", "loopover-orb[bot]", "loopover-review[bot]", "LOOPOVER[bot]", "loopover", "loopover-orb"]) {
expect(isOwnReviewThreadAuthor(env, login)).toBe(true);
}
});

it("does not match a third-party bot whose slug only ends in -gittensory[bot] (regression)", () => {
it("does not match a third-party bot whose slug only ends in -loopover[bot] (regression)", () => {
// A `\b` boundary also fires after a hyphen, so the unanchored regex misclassified these external bots as
// our own author and dropped their review-thread comments as self-authored non-blockers (fail-open).
for (const login of ["evil-gittensory[bot]", "x-gittensory[bot]", "not-gittensory", "gittensory-fork"]) {
for (const login of ["evil-loopover[bot]", "x-loopover[bot]", "not-loopover", "loopover-fork"]) {
expect(isOwnReviewThreadAuthor(env, login)).toBe(false);
}
});
Expand All @@ -2680,7 +2683,7 @@ describe("isOwnReviewThreadAuthor", () => {
expect(isOwnReviewThreadAuthor(renamed, "acme-review-orb[bot]")).toBe(true);
expect(isOwnReviewThreadAuthor(renamed, "acme-review")).toBe(true);
// The OLD slug no longer matches once an operator renames their App -- proves the literal is gone.
expect(isOwnReviewThreadAuthor(renamed, "gittensory[bot]")).toBe(false);
expect(isOwnReviewThreadAuthor(renamed, "loopover[bot]")).toBe(false);
});

it("a slug containing regex metacharacters is escaped, not interpreted (defensive)", () => {
Expand All @@ -2691,14 +2694,14 @@ describe("isOwnReviewThreadAuthor", () => {

it("fails closed when GITHUB_APP_SLUG is blank (misconfiguration)", () => {
const blank = createTestEnv({ GITHUB_APP_SLUG: "" });
expect(isOwnReviewThreadAuthor(blank, "gittensory[bot]")).toBe(false);
expect(isOwnReviewThreadAuthor(blank, "loopover[bot]")).toBe(false);
expect(isOwnReviewThreadAuthor(blank, "")).toBe(false);
});

it("fails closed when GITHUB_APP_SLUG is unset (the retired review App was deleted)", () => {
const unset = createTestEnv();
delete (unset as Partial<Env>).GITHUB_APP_SLUG;
expect(isOwnReviewThreadAuthor(unset, "gittensory[bot]")).toBe(false);
expect(isOwnReviewThreadAuthor(unset, "loopover[bot]")).toBe(false);
expect(isOwnReviewThreadAuthor(unset, "")).toBe(false);
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/unit/gate-check-policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ describe("resolveLinkedIssueAuthorLogins", () => {

it("falls back to a LIVE fetch for the author when the issue is not cached (#audit-3.11)", async () => {
const { privateKey } = generateKeyPairSync("rsa", { modulusLength: 2048 });
const env = createTestEnv({ GITHUB_APP_PRIVATE_KEY: privateKey.export({ type: "pkcs1", format: "pem" }).toString(), GITHUB_APP_SLUG: "gittensory" });
const env = createTestEnv({ GITHUB_APP_PRIVATE_KEY: privateKey.export({ type: "pkcs1", format: "pem" }).toString(), GITHUB_APP_SLUG: "loopover-orb" });
// Issue #50 is NOT in the local cache; a fresh GitHub fetch must still resolve its author so the
// self-authored detection isn't silently voided by a cache miss.
vi.stubGlobal("fetch", async (input: RequestInfo | URL) => {
Expand All @@ -795,7 +795,7 @@ describe("resolveLinkedIssueAuthorLogins", () => {

it("yields null for a cache-missed issue whose live fetch returns no facts (fail-safe)", async () => {
const { privateKey } = generateKeyPairSync("rsa", { modulusLength: 2048 });
const env = createTestEnv({ GITHUB_APP_PRIVATE_KEY: privateKey.export({ type: "pkcs1", format: "pem" }).toString(), GITHUB_APP_SLUG: "gittensory" });
const env = createTestEnv({ GITHUB_APP_PRIVATE_KEY: privateKey.export({ type: "pkcs1", format: "pem" }).toString(), GITHUB_APP_SLUG: "loopover-orb" });
vi.stubGlobal("fetch", async (input: RequestInfo | URL) => {
const url = input.toString();
if (url.includes("/access_tokens")) return Response.json({ token: "t" });
Expand All @@ -811,7 +811,7 @@ describe("resolveLinkedIssueAuthorLogins", () => {

it("live-fetches only the cache-missed issues, keeping the cached authors (mixed list)", async () => {
const { privateKey } = generateKeyPairSync("rsa", { modulusLength: 2048 });
const env = createTestEnv({ GITHUB_APP_PRIVATE_KEY: privateKey.export({ type: "pkcs1", format: "pem" }).toString(), GITHUB_APP_SLUG: "gittensory" });
const env = createTestEnv({ GITHUB_APP_PRIVATE_KEY: privateKey.export({ type: "pkcs1", format: "pem" }).toString(), GITHUB_APP_SLUG: "loopover-orb" });
await upsertRepositoryFromGitHub(env, { name: "repo", full_name: "owner/repo", private: false, owner: { login: "owner" } }, 1);
await upsertIssueFromGitHub(env, "owner/repo", { number: 10, title: "Cached", body: "", state: "open", user: { login: "alice" }, labels: [], html_url: "https://github.com/owner/repo/issues/10", created_at: "2026-01-01T00:00:00Z", updated_at: "2026-01-01T00:00:00Z" });
vi.stubGlobal("fetch", async (input: RequestInfo | URL) => {
Expand Down
20 changes: 10 additions & 10 deletions test/unit/github-comments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("GitHub PR intelligence comments", () => {
calls.push(`${init?.method ?? "GET"} ${url}`);
if (url.includes("/access_tokens")) return Response.json({ token: "installation-token" });
if (url.includes("/issues/12/comments") && (init?.method ?? "GET") === "GET") {
return Response.json([{ id: 101, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\nold body`, user: { login: "gittensory[bot]", type: "Bot" } }]);
return Response.json([{ id: 101, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\nold body`, user: { login: "loopover-orb[bot]", type: "Bot" } }]);
}
if (url.includes("/issues/comments/101") && init?.method === "PATCH") {
const body = JSON.parse(String(init.body)) as { body: string };
Expand Down Expand Up @@ -116,9 +116,9 @@ describe("GitHub PR intelligence comments", () => {
if (url.includes("/access_tokens")) return Response.json({ token: "installation-token" });
if (url.includes("/issues/12/comments") && (init?.method ?? "GET") === "GET") {
return Response.json([
{ id: 202, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\n\nreviewing placeholder`, user: { login: "gittensory-orb[bot]", type: "Bot" } },
{ id: 101, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\nold final`, user: { login: "gittensory-orb[bot]", type: "Bot" } },
{ id: 303, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\nsecond duplicate`, user: { login: "gittensory-orb[bot]", type: "Bot" } },
{ id: 202, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\n\nreviewing placeholder`, user: { login: "loopover-orb[bot]", type: "Bot" } },
{ id: 101, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\nold final`, user: { login: "loopover-orb[bot]", type: "Bot" } },
{ id: 303, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\nsecond duplicate`, user: { login: "loopover-orb[bot]", type: "Bot" } },
]);
}
if (url.includes("/issues/comments/202") && init?.method === "DELETE") return new Response(null, { status: 204 });
Expand All @@ -132,7 +132,7 @@ describe("GitHub PR intelligence comments", () => {
});

const result = await createOrUpdatePrIntelligenceComment(
createTestEnv({ GITHUB_APP_PRIVATE_KEY: privateKey, GITHUB_APP_SLUG: "gittensory-orb" }),
createTestEnv({ GITHUB_APP_PRIVATE_KEY: privateKey, GITHUB_APP_SLUG: "loopover-orb" }),
123,
"JSONbored/gittensory",
12,
Expand Down Expand Up @@ -164,7 +164,7 @@ describe("GitHub PR intelligence comments", () => {
);
}
// Bot comment is on page 2
return Response.json([{ id: 999, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\nold body`, user: { login: "gittensory[bot]", type: "Bot" } }]);
return Response.json([{ id: 999, body: `${PR_INTELLIGENCE_COMMENT_MARKER}\nold body`, user: { login: "loopover-orb[bot]", type: "Bot" } }]);
}
if (url.includes("/issues/comments/999") && init?.method === "PATCH") {
return Response.json({ id: 999, html_url: "https://github.com/comment/999" });
Expand Down Expand Up @@ -249,7 +249,7 @@ describe("GitHub PR intelligence comments", () => {
calls.push(`${init?.method ?? "GET"} ${url}`);
if (url.includes("/access_tokens")) return Response.json({ token: "installation-token" });
if (url.includes("/issues/12/comments") && (init?.method ?? "GET") === "GET") {
return Response.json([{ id: 101, body: "<!-- gittensory-pr-intelligence -->\nold body", user: { login: "gittensory[bot]", type: "Bot" } }]);
return Response.json([{ id: 101, body: "<!-- gittensory-pr-intelligence -->\nold body", user: { login: "loopover-orb[bot]", type: "Bot" } }]);
}
if (url.includes("/issues/comments/101") && init?.method === "PATCH") {
const body = JSON.parse(String(init.body)) as { body: string };
Expand Down Expand Up @@ -281,7 +281,7 @@ describe("GitHub PR intelligence comments", () => {
calls.push(`${init?.method ?? "GET"} ${url}`);
if (url.includes("/access_tokens")) return Response.json({ token: "installation-token" });
if (url.includes("/issues/12/comments") && (init?.method ?? "GET") === "GET") {
return Response.json([{ id: 202, body: "<!-- gittensory-agent-command -->\nold command body", user: { login: "gittensory[bot]", type: "Bot" } }]);
return Response.json([{ id: 202, body: "<!-- gittensory-agent-command -->\nold command body", user: { login: "loopover-orb[bot]", type: "Bot" } }]);
}
if (url.includes("/issues/comments/202") && init?.method === "PATCH") {
const body = JSON.parse(String(init.body)) as { body: string };
Expand Down Expand Up @@ -345,7 +345,7 @@ describe("GitHub PR intelligence comments", () => {
calls.push(`${init?.method ?? "GET"} ${url}`);
if (url.includes("/access_tokens")) return Response.json({ token: "installation-token" });
if (url.includes("/issues/12/comments") && (init?.method ?? "GET") === "GET") {
return Response.json([{ id: 101, body, html_url: "https://github.com/comment/101", user: { login: "gittensory[bot]", type: "Bot" } }]);
return Response.json([{ id: 101, body, html_url: "https://github.com/comment/101", user: { login: "loopover-orb[bot]", type: "Bot" } }]);
}
return new Response("not found", { status: 404 });
});
Expand All @@ -365,7 +365,7 @@ describe("GitHub PR intelligence comments", () => {
calls.push(`${init?.method ?? "GET"} ${url}`);
if (url.includes("/access_tokens")) return Response.json({ token: "installation-token" });
if (url.includes("/issues/12/comments") && (init?.method ?? "GET") === "GET") {
return Response.json([{ id: 202, body, user: { login: "gittensory[bot]", type: "Bot" } }]); // no html_url field
return Response.json([{ id: 202, body, user: { login: "loopover-orb[bot]", type: "Bot" } }]); // no html_url field
}
return new Response("not found", { status: 404 });
});
Expand Down
Loading
Loading