fix: expose conflict validation failures
This commit is contained in:
1 parent
51852fcfb2
commit
333bffb099
2 files changed
+60
-7
No files matched your search
@@ -32,11 +32,13 @@ const finalConfirmationSchema = z.object({
|
||||
concerns: z.array(z.string())
|
||||
});
|
||||
|
||||
const CONFLICT_TOTAL_TIMEOUT_MS = 25 * 60 * 1000;
|
||||
const CONFLICT_TOTAL_TIMEOUT_MS = 45 * 60 * 1000;
|
||||
const CONFLICT_INITIAL_AGENT_TIMEOUT_MS = 10 * 60 * 1000;
|
||||
const CONFLICT_CORRECTION_AGENT_TIMEOUT_MS = 5 * 60 * 1000;
|
||||
const CONFLICT_DIFF_CORRECTION_AGENT_TIMEOUT_MS = 5 * 60 * 1000;
|
||||
const CONFLICT_VALIDATION_REPAIR_AGENT_TIMEOUT_MS = 10 * 60 * 1000;
|
||||
const CONFLICT_VALIDATION_TIMEOUT_MS = 7 * 60 * 1000;
|
||||
const CONFLICT_CONFIRMATION_TIMEOUT_MS = 5 * 60 * 1000;
|
||||
const VALIDATION_LOG_OUTPUT_LIMIT = 12_000;
|
||||
|
||||
type SnapshotFile = {
|
||||
hash: string;
|
||||
@@ -239,7 +241,10 @@ export async function resolvePullRequestConflicts(
|
||||
const previousAgent = afterAgent;
|
||||
try {
|
||||
await runGooseAgent(buildDiffCheckRepairPrompt(commandFailureOutput(diffCheck)), snapshot, {
|
||||
timeoutMs: remainingConflictTime(resolutionStartedAt, CONFLICT_CORRECTION_AGENT_TIMEOUT_MS)
|
||||
timeoutMs: remainingConflictTime(
|
||||
resolutionStartedAt,
|
||||
CONFLICT_DIFF_CORRECTION_AGENT_TIMEOUT_MS
|
||||
)
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.toLowerCase().includes("timed out")) {
|
||||
@@ -293,7 +298,10 @@ export async function resolvePullRequestConflicts(
|
||||
testCommand: config.conflictTestCommand,
|
||||
output: validationSummary
|
||||
}), snapshot, {
|
||||
timeoutMs: remainingConflictTime(resolutionStartedAt, CONFLICT_CORRECTION_AGENT_TIMEOUT_MS)
|
||||
timeoutMs: remainingConflictTime(
|
||||
resolutionStartedAt,
|
||||
CONFLICT_VALIDATION_REPAIR_AGENT_TIMEOUT_MS
|
||||
)
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.toLowerCase().includes("timed out")) {
|
||||
@@ -548,7 +556,7 @@ export function describeConflictResolutionFailure(error: unknown, actorName = "g
|
||||
return "The isolated repository validation exceeded its 7-minute limit. No commit was pushed.";
|
||||
}
|
||||
if (message.includes("validation goose correction timed out")) {
|
||||
return "The focused validation-repair pass exceeded its 5-minute limit. No commit was pushed.";
|
||||
return "The focused validation-repair pass exceeded its 10-minute limit. No commit was pushed.";
|
||||
}
|
||||
if (message.includes("final goose confirmation timed out")) {
|
||||
return "The final read-only safety confirmation exceeded its 5-minute limit. No commit was pushed.";
|
||||
@@ -560,7 +568,7 @@ export function describeConflictResolutionFailure(error: unknown, actorName = "g
|
||||
return `${actorName} produced a candidate resolution, but the configured validation or final safety confirmation rejected it. No commit was pushed.`;
|
||||
}
|
||||
if (message.includes("conflict resolution timed out")) {
|
||||
return "Conflict repair exceeded its 25-minute total time budget and stopped safely. No commit was pushed.";
|
||||
return "Conflict repair exceeded its 45-minute total time budget and stopped safely. No commit was pushed.";
|
||||
}
|
||||
if (message.includes("initial goose conflict-editing pass timed out")) {
|
||||
return "The initial conflict-editing pass exceeded its 10-minute limit. No commit was pushed.";
|
||||
@@ -1033,9 +1041,37 @@ async function runConflictValidation(
|
||||
if (isValidationInfrastructureFailure(result)) {
|
||||
throw new Error(`Conflict validation infrastructure failed: ${commandFailureOutput(result)}`);
|
||||
}
|
||||
if (result.code !== 0) {
|
||||
logger.warn(
|
||||
{
|
||||
code: result.code,
|
||||
stdoutTail: formatValidationLogOutput(result.stdout),
|
||||
stderrTail: formatValidationLogOutput(result.stderr)
|
||||
},
|
||||
"Isolated repository validation failed; captured output is included for diagnosis."
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function formatValidationLogOutput(
|
||||
output: string,
|
||||
maxChars = VALIDATION_LOG_OUTPUT_LIMIT
|
||||
): string {
|
||||
const normalized = output
|
||||
.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "")
|
||||
.replace(/\r\n/g, "\n")
|
||||
.trim();
|
||||
if (!normalized) {
|
||||
return "(empty)";
|
||||
}
|
||||
if (normalized.length <= maxChars) {
|
||||
return normalized;
|
||||
}
|
||||
const omitted = normalized.length - maxChars;
|
||||
return `[truncated ${omitted} leading characters]\n${normalized.slice(-maxChars)}`;
|
||||
}
|
||||
|
||||
function remainingConflictTime(startedAt: number, perOperationLimitMs: number): number {
|
||||
const remaining = CONFLICT_TOTAL_TIMEOUT_MS - (Date.now() - startedAt);
|
||||
if (remaining <= 0) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
canAutoResolveConflicts,
|
||||
describeConflictResolutionFailure,
|
||||
diffSnapshotInventories,
|
||||
formatValidationLogOutput,
|
||||
isValidationInfrastructureFailure,
|
||||
parseDiffCheckWhitespaceDiagnostics,
|
||||
parseFinalConfirmation,
|
||||
@@ -99,12 +100,16 @@ test("conflict failures are actionable without exposing raw command output", ()
|
||||
);
|
||||
assert.match(
|
||||
describeConflictResolutionFailure(new Error("validation goose correction timed out")),
|
||||
/focused validation-repair pass.*5-minute limit/i
|
||||
/focused validation-repair pass.*10-minute limit/i
|
||||
);
|
||||
assert.match(
|
||||
describeConflictResolutionFailure(new Error("final goose confirmation timed out")),
|
||||
/final read-only safety confirmation.*5-minute limit/i
|
||||
);
|
||||
assert.match(
|
||||
describeConflictResolutionFailure(new Error("Conflict resolution timed out after 2700000ms")),
|
||||
/45-minute total time budget/i
|
||||
);
|
||||
assert.match(
|
||||
describeConflictResolutionFailure(new Error("Validation command failed"), "forumlify bot"),
|
||||
/^forumlify bot produced/
|
||||
@@ -119,6 +124,18 @@ test("conflict failures are actionable without exposing raw command output", ()
|
||||
);
|
||||
});
|
||||
|
||||
test("validation failure logs are bounded, readable, and keep the useful tail", () => {
|
||||
assert.equal(formatValidationLogOutput(""), "(empty)");
|
||||
assert.equal(
|
||||
formatValidationLogOutput("\u001b[31mfailed assertion\u001b[0m\r\nexpected true"),
|
||||
"failed assertion\nexpected true"
|
||||
);
|
||||
assert.equal(
|
||||
formatValidationLogOutput("prefix-useful-tail", 11),
|
||||
"[truncated 7 leading characters]\nuseful-tail"
|
||||
);
|
||||
});
|
||||
|
||||
test("validation infrastructure failures are not sent to the code-repair agent", () => {
|
||||
assert.equal(isValidationInfrastructureFailure({
|
||||
code: 1,
|
||||
|
||||
Reference in new issue
Block a user