fix: bound conflict repair runtime

This commit is contained in:
lezi-fun committed 2026-08-14 13:28:18 +08:00
1 parent 31756e84ba
commit 785cddedd9
4 files changed
+292 -137

No files matched your search

+15 -4
View File
@@ -6,7 +6,8 @@ import {
buildConflictReviewDiffArgs,
canAutoResolveConflicts,
describeConflictResolutionFailure,
diffSnapshotInventories
diffSnapshotInventories,
parseFinalConfirmation
} from "../src/review/conflictResolver.js";
const eligible = {
@@ -40,7 +41,7 @@ test("conflict final review scopes the diff to agent-changed files", () => {
"diff",
"--cached",
"--no-ext-diff",
"--unified=80",
"--unified=24",
"--",
"server.js",
"public/js/app.js"
@@ -122,11 +123,21 @@ test("snapshot inventory detects related file additions, changes, and deletions"
test("validation repair prompt requires the exact command without allowing test weakening", () => {
const prompt = buildValidationRepairPrompt({
testCommand: "npm ci && npm test",
summary: "One compatibility test failed.",
concerns: ["The handler and its test disagree."]
output: "Exit code: 1\nThe handler and its test disagree."
});
assert.match(prompt, /npm ci && npm test/);
assert.match(prompt, /handler and its test disagree/);
assert.match(prompt, /do not .*weaken\/delete tests/i);
assert.match(prompt, /related validation failures/i);
});
test("final confirmation parser accepts a JSON object surrounded by prose", () => {
assert.deepEqual(
parseFinalConfirmation('Result:\n{"safeToCommit":true,"summary":"validated","concerns":[]}\nDone.'),
{ safeToCommit: true, summary: "validated", concerns: [] }
);
assert.throws(
() => parseFinalConfirmation("safe to commit"),
/required JSON object/
);
});
+15
View File
@@ -3,6 +3,7 @@ import test from "node:test";
import {
buildGooseAgentDockerArgs,
buildGooseAgentEnvironment,
buildIsolatedWorkspaceCommandDockerArgs,
buildWorkspacePermissionDockerArgs,
extractGooseFinalText
} from "../src/ai/gooseCli.js";
@@ -26,6 +27,20 @@ test("goose agent mounts the workflow binary read-only and keeps a visible insta
assert.equal(args.at(-1), "introduce this pull request");
});
test("isolated validation receives the repository but no model or GitHub credentials", () => {
const args = buildIsolatedWorkspaceCommandDockerArgs({
containerName: "ghbot-validation-test",
realWorkingDirectory: "/tmp/worktree",
command: "npm ci && npm test"
});
assert.ok(args.includes("type=bind,source=/tmp/worktree,target=/workspace"));
assert.ok(args.includes("HOME=/tmp/ghbot-validation-home"));
assert.ok(args.includes("CI=true"));
assert.equal(args.at(-1), "npm ci && npm test");
assert.equal(args.some((arg) => /OPENAI|GITHUB|GHBOT_GIT_TOKEN/.test(arg)), false);
});
test("goose agent can fall back to installing inside the container", () => {
const args = buildGooseAgentDockerArgs({
containerName: "ghbot-agent-test",