From f29e52478ad3e6d1b978a1b7d628fef7b0756902 Mon Sep 17 00:00:00 2001 From: monsterdavidliu-ux Date: Thu, 28 May 2026 22:55:49 +0000 Subject: [PATCH 1/3] ... --- src/github/commands.ts | 220 +++++++++++++++++++++++++++--- test/unit/github-commands.test.ts | 159 ++++++++++++++++++++- 2 files changed, 359 insertions(+), 20 deletions(-) diff --git a/src/github/commands.ts b/src/github/commands.ts index 9d5e4c8e2..9d1e024bd 100644 --- a/src/github/commands.ts +++ b/src/github/commands.ts @@ -1,6 +1,7 @@ import { AGENT_COMMAND_COMMENT_MARKER } from "./comments"; import type { AgentRunBundle } from "../services/agent-orchestrator"; import type { GittensorContributorSnapshot, OfficialGittensorMinerDetection } from "../gittensor/api"; +import type { AgentActionRecord } from "../types"; import type { GitHubIssuePayload, PullRequestRecord, RepositoryRecord } from "../types"; export type GittensoryMentionCommandName = "help" | "preflight" | "blockers" | "duplicate-check" | "miner-context" | "next-action"; @@ -13,6 +14,15 @@ export type GittensoryMentionCommand = { const COMMANDS = new Set(["help", "preflight", "blockers", "duplicate-check", "miner-context", "next-action"]); const MAINTAINER_ASSOCIATIONS = new Set(["OWNER", "MEMBER", "COLLABORATOR"]); +const COMMAND_TITLES: Record = { + help: "Gittensory command help", + preflight: "Gittensory preflight", + blockers: "Gittensory readiness blockers", + "duplicate-check": "Gittensory duplicate & WIP check", + "miner-context": "Gittensory miner context", + "next-action": "Gittensory next step", +}; + export function parseGittensoryMentionCommand(body: string | null | undefined): GittensoryMentionCommand | null { if (!body) return null; const match = body.match(/(?:^|\s)@gittensory(?:\s+([a-z-]+))?/i); @@ -55,16 +65,10 @@ export function buildPublicAgentCommandComment(args: { bundle?: AgentRunBundle | null | undefined; }): string { const repoFullName = args.repo?.fullName ?? args.pullRequest?.repoFullName ?? "this repository"; - const title = "Gittensory agent context"; - const sections = - args.command.name === "help" - ? helpSections() - : args.command.name === "miner-context" - ? minerContextSections(args.officialMiner) - : actionSections(args.bundle); + const sections = commandSections(args.command.name, args.bundle, args.officialMiner); const body = [ AGENT_COMMAND_COMMENT_MARKER, - `### ${title}`, + `### ${COMMAND_TITLES[args.command.name]}`, "", `Command: \`@gittensory ${args.command.name}\``, `Scope: ${repoFullName}#${args.issue.number}`, @@ -76,6 +80,27 @@ export function buildPublicAgentCommandComment(args: { return sanitizePublicComment(body); } +function commandSections( + command: GittensoryMentionCommandName, + bundle: AgentRunBundle | null | undefined, + officialMiner: GittensorContributorSnapshot | null | undefined, +): string[] { + switch (command) { + case "help": + return helpSections(); + case "miner-context": + return minerContextSections(officialMiner); + case "preflight": + return preflightSections(bundle); + case "blockers": + return blockersSections(bundle); + case "duplicate-check": + return duplicateCheckSections(bundle); + case "next-action": + return nextActionSections(bundle); + } +} + function helpSections(): string[] { return [ "**Commands**", @@ -103,26 +128,187 @@ function minerContextSections(miner: GittensorContributorSnapshot | null | undef ]; } -function actionSections(bundle: AgentRunBundle | null | undefined): string[] { - const actions = bundle?.actions ?? []; +function preflightSections(bundle: AgentRunBundle | null | undefined): string[] { if (bundle?.run.status === "needs_snapshot_refresh") { - return ["**Next step**", "", "- Gittensory is refreshing the contributor decision snapshot. Try the command again shortly."]; + return refreshSections("preflight"); } + const actions = pickActions(bundle, (action) => + action.actionType === "preflight_branch" || action.actionType === "prepare_pr_packet" || /preflight|pr packet|linked context|validation/i.test(action.publicSafeSummary), + ); if (actions.length === 0) { - return ["**Next step**", "", "- No public-safe action is available from the current cached context."]; + return emptySections("preflight"); + } + return [ + "**Preflight summary**", + "", + ...actions.slice(0, 3).flatMap((action) => formatActionBullets(action, { includeBlockers: true, includeRerun: true })), + ]; +} + +function blockersSections(bundle: AgentRunBundle | null | undefined): string[] { + if (bundle?.run.status === "needs_snapshot_refresh") { + return refreshSections("blockers"); + } + const actions = pickActions(bundle, (action) => + action.actionType === "explain_score_blockers" || action.blockedBy.length > 0 || action.status === "blocked", + ); + if (actions.length === 0) { + return ["**Readiness blockers**", "", "- No public readiness blockers are visible from the current cached context."]; + } + const lines = ["**Readiness blockers**", ""]; + for (const action of actions.slice(0, 4)) { + if (action.why.length > 0) { + lines.push(...action.why.slice(0, 4).map((item) => `- ${publicBlockerDetail(item)}`)); + continue; + } + lines.push(...formatActionBullets(action, { includeBlockers: true, includeRerun: false })); + } + return dedupeBulletLines(lines); +} + +function duplicateCheckSections(bundle: AgentRunBundle | null | undefined): string[] { + if (bundle?.run.status === "needs_snapshot_refresh") { + return refreshSections("duplicate-check"); + } + const actions = pickActions( + bundle, + (action) => action.actionType === "check_duplicate_risk" || mentionsDuplicateRisk(action), + ); + if (actions.length === 0) { + return [ + "**Duplicate & WIP caution**", + "", + "- No duplicate or work-in-progress collision signal is visible from the current cached context.", + "- Compare linked issues, open PRs, and recent merges before requesting detailed review.", + ]; + } + const lines = ["**Duplicate & WIP caution**", ""]; + for (const action of actions.slice(0, 4)) { + lines.push(`- ${publicBlockerDetail(action.publicSafeSummary)}`); + const caution = [...action.why, action.riskImpact ?? ""] + .filter((item) => mentionsDuplicateRiskText(item)) + .slice(0, 3) + .map((item) => `- ${publicBlockerDetail(item)}`); + lines.push(...caution); + } + return dedupeBulletLines(lines); +} + +function nextActionSections(bundle: AgentRunBundle | null | undefined): string[] { + if (bundle?.run.status === "needs_snapshot_refresh") { + return refreshSections("next-action"); + } + const actions = pickActions(bundle, (action) => + ["choose_next_work", "cleanup_existing_prs", "monitor_existing_pr", "explain_repo_fit"].includes(action.actionType), + ); + if (actions.length === 0) { + return emptySections("next-action"); } const top = actions[0]!; return [ - "**Recommended public-safe next step**", + "**Recommended next step**", + "", + `- ${publicBlockerDetail(top.publicSafeSummary)}`, + ...(top.blockedBy.length > 0 + ? ["", "**Before proceeding**", "", ...top.blockedBy.slice(0, 4).map((item) => `- ${publicBlockerLabel(item)}`)] + : []), + ...(top.rerunWhen ? ["", "**Rerun when**", "", `- ${publicBlockerDetail(top.rerunWhen)}`] : []), + ]; +} + +function refreshSections(command: Exclude): string[] { + const labels: Record = { + preflight: "Preflight snapshot refresh", + blockers: "Blocker snapshot refresh", + "duplicate-check": "Duplicate-check snapshot refresh", + "next-action": "Next-action snapshot refresh", + }; + return [ + `**${labels[command]}**`, "", - `- ${top.publicSafeSummary}`, - ...(top.blockedBy.length > 0 ? ["", "**Public readiness blockers**", "", ...top.blockedBy.slice(0, 4).map((item) => `- ${sanitizePublicComment(item)}`)] : []), - ...(top.rerunWhen ? ["", "**Rerun when**", "", `- ${sanitizePublicComment(top.rerunWhen)}`] : []), + "- Gittensory is refreshing the contributor decision snapshot. Try the command again shortly.", ]; } +function emptySections(command: Exclude): string[] { + const labels: Record = { + preflight: "Preflight summary", + blockers: "Readiness blockers", + "duplicate-check": "Duplicate & WIP caution", + "next-action": "Recommended next step", + }; + return [`**${labels[command]}**`, "", "- No public-safe context is available from the current cached snapshot."]; +} + +function pickActions( + bundle: AgentRunBundle | null | undefined, + predicate: (action: AgentActionRecord) => boolean, +): AgentActionRecord[] { + const actions = bundle?.actions ?? []; + const matched = actions.filter(predicate); + return matched.length > 0 ? matched : actions.slice(0, 2); +} + +function formatActionBullets( + action: AgentActionRecord, + options: { includeBlockers: boolean; includeRerun: boolean }, +): string[] { + const lines = [`- ${publicBlockerDetail(action.publicSafeSummary)}`]; + if (options.includeBlockers && action.blockedBy.length > 0) { + lines.push(...action.blockedBy.slice(0, 4).map((item) => `- ${publicBlockerLabel(item)}`)); + } + if (options.includeRerun && action.rerunWhen) { + lines.push(`- Rerun when: ${publicBlockerDetail(action.rerunWhen)}`); + } + return lines; +} + +function mentionsDuplicateRisk(action: AgentActionRecord): boolean { + return [action.publicSafeSummary, action.recommendation, action.riskImpact ?? "", ...action.why, ...action.blockedBy].some((item) => + mentionsDuplicateRiskText(item), + ); +} + +function mentionsDuplicateRiskText(value: string): boolean { + return /\b(duplicate|overlap|wip|collision|concurrent|in[- ]progress)\b/i.test(value); +} + +function publicBlockerLabel(code: string): string { + const normalized = code.trim().toLowerCase(); + const labels: Record = { + likely_duplicate: "Possible overlap with existing work", + open_pr_pressure: "Open pull request queue pressure", + closed_pr_credibility: "Closed pull request credibility signal", + inactive_or_unknown_lane: "Repository lane is inactive or unknown", + issue_discovery_only: "Repository is issue-discovery only", + low_credibility: "Contributor credibility needs improvement", + maintainer_lane: "Maintainer-lane activity is separate from outside-contributor work", + }; + return labels[normalized] ?? sanitizePublicComment(code.replace(/_/g, " ")); +} + +function publicBlockerDetail(value: string): string { + return sanitizePublicComment( + value + .replace(/\blikely_duplicate\b/gi, "possible overlap with existing work") + .replace(/\bcheck_duplicate_risk\b/gi, "duplicate-risk review") + .replace(/\bopen_pr_pressure\b/gi, "open pull request pressure"), + ); +} + +function dedupeBulletLines(lines: string[]): string[] { + const seen = new Set(); + return lines.filter((line) => { + if (!line.startsWith("- ")) return true; + if (seen.has(line)) return false; + seen.add(line); + return true; + }); +} + export function sanitizePublicComment(value: string): string { return value .replace(/\b(raw trust score|trust score|wallet|hotkey|coldkey|seed phrase|mnemonic)\b/gi, "private context") - .replace(/\b(estimated score|score estimate|reward estimate|payout|farming)\b/gi, "private context"); + .replace(/\b(estimated score|score estimate|reward estimate|payout|farming)\b/gi, "private context") + .replace(/\blikely_duplicate\b/gi, "possible overlap with existing work"); } diff --git a/test/unit/github-commands.test.ts b/test/unit/github-commands.test.ts index 20fbb4453..3082016c2 100644 --- a/test/unit/github-commands.test.ts +++ b/test/unit/github-commands.test.ts @@ -100,6 +100,59 @@ describe("GitHub mention commands", () => { expect(sanitizePublicComment("wallet hotkey payout")).not.toMatch(/wallet|hotkey|payout/i); }); + it("renders command-specific sections for preflight, blockers, duplicate-check, and next-action", () => { + const bundle = sampleBundle(); + + const preflight = buildPublicAgentCommandComment({ + command: parseGittensoryMentionCommand("@gittensory preflight")!, + repo: null, + issue: { number: 10, title: "PR", state: "open", pull_request: {} }, + pullRequest: null, + actorKind: "author", + bundle, + }); + expect(preflight).toContain("### Gittensory preflight"); + expect(preflight).toContain("**Preflight summary**"); + expect(preflight).toContain("Run local branch preflight first."); + + const blockers = buildPublicAgentCommandComment({ + command: parseGittensoryMentionCommand("@gittensory blockers")!, + repo: null, + issue: { number: 11, title: "PR", state: "open", pull_request: {} }, + pullRequest: null, + actorKind: "maintainer", + bundle: blockerBundle(), + }); + expect(blockers).toContain("### Gittensory readiness blockers"); + expect(blockers).toContain("**Readiness blockers**"); + expect(blockers).toContain("open pull request pressure"); + + const duplicateCheck = buildPublicAgentCommandComment({ + command: parseGittensoryMentionCommand("@gittensory duplicate-check")!, + repo: null, + issue: { number: 12, title: "PR", state: "open", pull_request: {} }, + pullRequest: null, + actorKind: "maintainer", + bundle: duplicateBundle(), + }); + expect(duplicateCheck).toContain("### Gittensory duplicate & WIP check"); + expect(duplicateCheck).toContain("**Duplicate & WIP caution**"); + expect(duplicateCheck).toContain("possible overlap with existing work"); + expect(duplicateCheck).not.toMatch(/\blikely_duplicate\b/i); + + const nextAction = buildPublicAgentCommandComment({ + command: parseGittensoryMentionCommand("@gittensory next-action")!, + repo: null, + issue: { number: 13, title: "PR", state: "open", pull_request: {} }, + pullRequest: null, + actorKind: "author", + bundle, + }); + expect(nextAction).toContain("### Gittensory next step"); + expect(nextAction).toContain("**Recommended next step**"); + expect(nextAction).toContain("After tests pass."); + }); + it("renders help, miner-context fallback, refresh, and empty-action responses", () => { const help = buildPublicAgentCommandComment({ command: parseGittensoryMentionCommand("@gittensory help")!, @@ -153,7 +206,7 @@ describe("GitHub mention commands", () => { summary: "refresh", }, }); - expect(refresh).toContain("refreshing the contributor decision snapshot"); + expect(refresh).toContain("**Blocker snapshot refresh**"); const empty = buildPublicAgentCommandComment({ command: parseGittensoryMentionCommand("@gittensory next-action")!, @@ -177,7 +230,8 @@ describe("GitHub mention commands", () => { summary: "empty", }, }); - expect(empty).toContain("No public-safe action is available"); + expect(empty).toContain("**Recommended next step**"); + expect(empty).toContain("No public-safe context is available"); const noBundle = buildPublicAgentCommandComment({ command: parseGittensoryMentionCommand("@gittensory preflight")!, @@ -186,7 +240,8 @@ describe("GitHub mention commands", () => { pullRequest: null, actorKind: "author", }); - expect(noBundle).toContain("No public-safe action is available"); + expect(noBundle).toContain("**Preflight summary**"); + expect(noBundle).toContain("No public-safe context is available"); const withPrFallbackScope = buildPublicAgentCommandComment({ command: parseGittensoryMentionCommand("@gittensory next-action")!, @@ -230,6 +285,104 @@ describe("GitHub mention commands", () => { }); }); +function sampleBundle() { + return { + run: { + id: "run-action", + objective: "action", + actorLogin: "oktofeesh1", + surface: "github_comment" as const, + mode: "copilot" as const, + status: "completed" as const, + dataQualityStatus: "complete" as const, + payload: {}, + }, + actions: [ + { + id: "action", + runId: "run-action", + actionType: "choose_next_work" as const, + status: "recommended" as const, + recommendation: "recommendation", + why: [], + blockedBy: [], + publicSafeSummary: "Run local branch preflight first.", + rerunWhen: "After tests pass.", + approvalRequired: true, + safetyClass: "private" as const, + payload: {}, + }, + ], + contextSnapshots: [], + summary: "done", + }; +} + +function blockerBundle() { + return { + run: { + id: "run-blockers", + objective: "blockers", + actorLogin: "maintainer", + surface: "github_comment" as const, + mode: "copilot" as const, + status: "completed" as const, + dataQualityStatus: "complete" as const, + payload: {}, + }, + actions: [ + { + id: "blocker-action", + runId: "run-blockers", + actionType: "explain_score_blockers" as const, + status: "blocked" as const, + recommendation: "Resolve blockers", + why: ["open_pr_pressure: 5 open PR(s) create review-pressure risk."], + blockedBy: ["open_pr_pressure"], + publicSafeSummary: "Resolve queue pressure before opening more work.", + approvalRequired: true, + safetyClass: "private" as const, + payload: {}, + }, + ], + contextSnapshots: [], + summary: "blockers", + }; +} + +function duplicateBundle() { + return { + run: { + id: "run-duplicate", + objective: "duplicate-check", + actorLogin: "maintainer", + surface: "github_comment" as const, + mode: "copilot" as const, + status: "completed" as const, + dataQualityStatus: "complete" as const, + payload: {}, + }, + actions: [ + { + id: "duplicate-action", + runId: "run-duplicate", + actionType: "check_duplicate_risk" as const, + status: "watch" as const, + recommendation: "Compare overlap", + why: ["likely_duplicate cluster detected against an active PR."], + blockedBy: ["likely_duplicate"], + riskImpact: "High-risk duplicate/WIP collision cluster.", + publicSafeSummary: "Compare against linked issues and active PRs before detailed review.", + approvalRequired: true, + safetyClass: "private" as const, + payload: {}, + }, + ], + contextSnapshots: [], + summary: "duplicate", + }; +} + function minerSnapshot() { return { source: "gittensor_api" as const, From a1b4e03670bedced1accac8831c85c8ea8446cd5 Mon Sep 17 00:00:00 2001 From: monsterdavidliu-ux Date: Fri, 29 May 2026 05:11:44 +0000 Subject: [PATCH 2/3] fix(github-app): address PR review for command-specific responses Include duplicate-check blocker labels, dedupe sanitizer footer output, and expand public-comment leakage coverage in unit tests. --- src/github/commands.ts | 13 +++++++++---- test/unit/github-commands.test.ts | 8 ++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/github/commands.ts b/src/github/commands.ts index 9d1e024bd..c1c23b630 100644 --- a/src/github/commands.ts +++ b/src/github/commands.ts @@ -75,7 +75,7 @@ export function buildPublicAgentCommandComment(args: { "", ...sections, "", - "_Advisory context only. This public comment intentionally excludes private ranking, wallet, payout, and reviewability internals._", + "_Advisory context only. Public comments exclude non-public contributor signals and reviewability internals._", ].join("\n"); return sanitizePublicComment(body); } @@ -185,8 +185,11 @@ function duplicateCheckSections(bundle: AgentRunBundle | null | undefined): stri const lines = ["**Duplicate & WIP caution**", ""]; for (const action of actions.slice(0, 4)) { lines.push(`- ${publicBlockerDetail(action.publicSafeSummary)}`); + for (const code of action.blockedBy.slice(0, 3)) { + lines.push(`- ${publicBlockerLabel(code)}`); + } const caution = [...action.why, action.riskImpact ?? ""] - .filter((item) => mentionsDuplicateRiskText(item)) + .filter((item) => item.trim().length > 0 && (mentionsDuplicateRiskText(item) || /\blikely_duplicate\b/i.test(item))) .slice(0, 3) .map((item) => `- ${publicBlockerDetail(item)}`); lines.push(...caution); @@ -307,8 +310,10 @@ function dedupeBulletLines(lines: string[]): string[] { } export function sanitizePublicComment(value: string): string { - return value + const sanitized = value .replace(/\b(raw trust score|trust score|wallet|hotkey|coldkey|seed phrase|mnemonic)\b/gi, "private context") - .replace(/\b(estimated score|score estimate|reward estimate|payout|farming)\b/gi, "private context") + .replace(/\b(estimated score|score estimate|reward estimate|payout|farming|reviewability)\b/gi, "private context") + .replace(/\b(private ranking|private rankings)\b/gi, "private context") .replace(/\blikely_duplicate\b/gi, "possible overlap with existing work"); + return sanitized.replace(/private context(?:,\s*private context)+/gi, "private context"); } diff --git a/test/unit/github-commands.test.ts b/test/unit/github-commands.test.ts index 3082016c2..bc0b60dfb 100644 --- a/test/unit/github-commands.test.ts +++ b/test/unit/github-commands.test.ts @@ -96,8 +96,12 @@ describe("GitHub mention commands", () => { }); expect(body).toContain(""); expect(body).toContain("Scope: this repository#12"); - expect(body).not.toMatch(/wallet|hotkey|coldkey|estimated score|reward estimate|payout|farming|raw trust score/i); - expect(sanitizePublicComment("wallet hotkey payout")).not.toMatch(/wallet|hotkey|payout/i); + expect(body).not.toMatch(/wallet|hotkey|coldkey|estimated score|reward estimate|payout|farming|raw trust score|reviewability|private ranking/i); + expect(body).not.toMatch(/private context,\s*private context/i); + expect(sanitizePublicComment("wallet hotkey payout reviewability private ranking")).not.toMatch( + /wallet|hotkey|payout|reviewability|private ranking/i, + ); + expect(sanitizePublicComment("private ranking, wallet, payout")).toBe("private context"); }); it("renders command-specific sections for preflight, blockers, duplicate-check, and next-action", () => { From 9b3a22940fbc74d8441e23b502811cdaf08a39fc Mon Sep 17 00:00:00 2001 From: monsterdavidliu-ux Date: Fri, 29 May 2026 06:23:05 +0000 Subject: [PATCH 3/3] test(github-app): improve command coverage for CI branch threshold Add edge-case tests for blocker label fallbacks, duplicate-risk heuristics, preflight rerun bullets, and duplicate-check action fallback picking. --- test/unit/github-commands.test.ts | 136 ++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/test/unit/github-commands.test.ts b/test/unit/github-commands.test.ts index bc0b60dfb..206e2dde0 100644 --- a/test/unit/github-commands.test.ts +++ b/test/unit/github-commands.test.ts @@ -287,8 +287,144 @@ describe("GitHub mention commands", () => { expect(withPrFallbackScope).toContain("Scope: owner/from-pr#5"); expect(withPrFallbackScope).toContain("After tests pass."); }); + + it("covers blocker label fallbacks, rerun bullets, and duplicate-risk heuristics", () => { + const blockersWithFallbackLabel = buildPublicAgentCommandComment({ + command: parseGittensoryMentionCommand("@gittensory blockers")!, + repo: null, + issue: { number: 20, title: "PR", state: "open", pull_request: {} }, + pullRequest: null, + actorKind: "maintainer", + bundle: { + run: completedRun("run-blockers-fallback"), + actions: [ + { + id: "blocker-fallback", + runId: "run-blockers-fallback", + actionType: "monitor_existing_pr", + status: "blocked", + recommendation: "Wait for review capacity", + why: [], + blockedBy: ["custom_signal_code"], + publicSafeSummary: "Reduce concurrent review load.", + approvalRequired: true, + safetyClass: "private", + payload: {}, + }, + ], + contextSnapshots: [], + summary: "blockers", + }, + }); + expect(blockersWithFallbackLabel).toContain("custom signal code"); + expect(blockersWithFallbackLabel).toContain("Reduce concurrent review load."); + + const duplicateViaRecommendation = buildPublicAgentCommandComment({ + command: parseGittensoryMentionCommand("@gittensory duplicate-check")!, + repo: null, + issue: { number: 21, title: "PR", state: "open", pull_request: {} }, + pullRequest: null, + actorKind: "maintainer", + bundle: { + run: completedRun("run-duplicate-rec"), + actions: [ + { + id: "duplicate-rec", + runId: "run-duplicate-rec", + actionType: "monitor_existing_pr", + status: "watch", + recommendation: "Compare WIP overlap with active pull requests", + why: ["Maintainer queue is busy"], + blockedBy: [], + riskImpact: "Concurrent review pressure", + publicSafeSummary: "Review linked issues before requesting detailed review.", + approvalRequired: true, + safetyClass: "private", + payload: {}, + }, + ], + contextSnapshots: [], + summary: "duplicate", + }, + }); + expect(duplicateViaRecommendation).toContain("**Duplicate & WIP caution**"); + expect(duplicateViaRecommendation).toMatch(/overlap|WIP|Concurrent/i); + + const preflightWithRerun = buildPublicAgentCommandComment({ + command: parseGittensoryMentionCommand("@gittensory preflight")!, + repo: null, + issue: { number: 22, title: "PR", state: "open", pull_request: {} }, + pullRequest: null, + actorKind: "author", + bundle: { + run: completedRun("run-preflight-rerun"), + actions: [ + { + id: "preflight-rerun", + runId: "run-preflight-rerun", + actionType: "prepare_pr_packet", + status: "recommended", + recommendation: "Prepare packet", + why: [], + blockedBy: ["open_pr_pressure"], + publicSafeSummary: "Run local branch preflight first.", + rerunWhen: "After CI completes.", + approvalRequired: true, + safetyClass: "private", + payload: {}, + }, + ], + contextSnapshots: [], + summary: "preflight", + }, + }); + expect(preflightWithRerun).toContain("Rerun when:"); + expect(preflightWithRerun).toContain("Open pull request queue pressure"); + + const duplicateFallbackPick = buildPublicAgentCommandComment({ + command: parseGittensoryMentionCommand("@gittensory duplicate-check")!, + repo: null, + issue: { number: 23, title: "PR", state: "open", pull_request: {} }, + pullRequest: null, + actorKind: "maintainer", + bundle: { + run: completedRun("run-duplicate-fallback"), + actions: [ + { + id: "fallback-action", + runId: "run-duplicate-fallback", + actionType: "choose_next_work", + status: "recommended", + recommendation: "Pick the next issue", + why: [], + blockedBy: [], + publicSafeSummary: "No duplicate signal in this fallback action.", + approvalRequired: true, + safetyClass: "private", + payload: {}, + }, + ], + contextSnapshots: [], + summary: "fallback", + }, + }); + expect(duplicateFallbackPick).toContain("No duplicate signal in this fallback action."); + }); }); +function completedRun(id: string) { + return { + id, + objective: "test", + actorLogin: "oktofeesh1", + surface: "github_comment" as const, + mode: "copilot" as const, + status: "completed" as const, + dataQualityStatus: "complete" as const, + payload: {}, + }; +} + function sampleBundle() { return { run: {