feat(engine): harden review pipeline with strict scope, build retry, and E2E tests

Improve the plan→review→approve→merge agent pipeline:

- Harden verdict extraction with JSON block parsing and anchored regexes
- Consolidate legacy/new merger conflict APIs into thin deprecated wrappers
- Add configurable strict scope enforcement (strictScopeEnforcement setting)
- Add build retry with timeout to merger (buildRetryCount, buildTimeoutMs)
- Add handleChangesRequested to PrCommentHandler for review feedback loop
- Remove dead code: handleFsChange, processTaskChange, unused imports/fields
- Add E2E multi-verdict sequence tests for the full review pipeline
- Fix unused parameter warnings across engine and core packages

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-04 00:29:34 -07:00
parent 1d45cdb82b
commit cf83579a34
11 changed files with 427 additions and 357 deletions

View File

@@ -151,6 +151,45 @@ export class PrCommentHandler {
return lines.join("\n");
}
/**
* Handle "changes requested" PR review state.
* Moves the task back to in-progress with reviewer feedback as a steering comment,
* closing the feedback loop so the agent can address the requested changes.
*/
async handleChangesRequested(
taskId: string,
prInfo: PrInfo,
reviewerLogin: string,
reviewBody: string,
): Promise<void> {
try {
const task = await this.store.getTask(taskId);
if (task.column !== "in-review") {
prMonitorLog.log(`Task ${taskId} not in-review (${task.column}), skipping changes-requested handling`);
return;
}
// Add reviewer feedback as a steering comment
const feedbackText = [
`**Changes Requested** by @${reviewerLogin} on PR #${prInfo.number}`,
"",
reviewBody ? reviewBody.slice(0, 800) : "(no review body)",
"",
"Please address the requested changes and update the PR.",
].join("\n");
await this.store.addTaskComment(taskId, feedbackText, "agent");
await this.store.moveTask(taskId, "in-progress");
await this.store.logEntry(
taskId,
`PR #${prInfo.number}: changes requested by @${reviewerLogin} — moved back to in-progress`,
);
prMonitorLog.log(`Task ${taskId} moved to in-progress after changes requested on PR #${prInfo.number}`);
} catch (err) {
prMonitorLog.error(`Failed to handle changes-requested for ${taskId}:`, err);
}
}
/**
* Create a follow-up task when a PR is closed with unaddressed feedback.
* This is called when a PR is merged or closed.