fix(FN-branch-group): add engine.promoteBranchGroup bridge method (U4)

The dashboard promote route called engine.promoteBranchGroup(groupId) as a
method that never existed — only a standalone coordinator function did — so
the route was dead, masked by a vi.fn mock in the test. Add the real method on
ProjectEngine delegating to the coordinator (resolving store/cwd/settings like
attemptBranchGroupPromotion), and de-mock the test so it now fails if the
method goes missing. No PR-creation behavior yet (U5).
This commit is contained in:
gsxdsm
2026-06-03 09:46:54 -07:00
parent cad44b1f56
commit 508b9c44d0
3 changed files with 202 additions and 12 deletions

View File

@@ -27,7 +27,7 @@ import { CronRunner, createAiPromptExecutor } from "./cron-runner.js";
import type { RoutineRunner } from "./routine-runner.js";
import { aiMergeTask, sweepStaleAutostashes, VerificationError } from "./merger.js";
import { runAiMerge } from "./merger-ai.js";
import { promoteBranchGroup } from "./group-merge-coordinator.js";
import { promoteBranchGroup, type BranchGroupPromotionResult } from "./group-merge-coordinator.js";
import { PRIORITY_MERGE } from "./concurrency.js";
import { runtimeLog } from "./logger.js";
import type { HeartbeatTriggerScheduler } from "./agent-heartbeat.js";
@@ -924,6 +924,45 @@ export class ProjectEngine {
return this.internalEnqueueMerge(taskId);
}
/**
* Promote a shared branch group: merge the group branch into the integration
* branch and reconcile `prState` (completion-gated, idempotent).
*
* This is the single engine bridge method (KTD5) that the dashboard promote
* route reaches via the `promoteBranchGroup` option callback in
* `register-integrated-routers.ts`. It resolves the same store / rootDir /
* settings context the internal auto-promotion path (`attemptBranchGroupPromotion`)
* uses and delegates to the standalone coordinator function — no logic is
* duplicated here.
*/
async promoteBranchGroup(groupId: string): Promise<BranchGroupPromotionResult> {
const store = this.runtime.getTaskStore();
const cwd = this.config.workingDirectory;
const settings = await store.getSettings();
const promotionSettings = {
autoMerge: settings.autoMerge,
globalPause: settings.globalPause,
enginePaused: settings.enginePaused,
mergeStrategy: settings.mergeStrategy,
integrationBranch: settings.integrationBranch,
baseBranch: settings.baseBranch,
};
return await promoteBranchGroup({
store,
rootDir: cwd,
groupId,
settings: promotionSettings,
recordAudit: async (event) => {
await store.recordRunAuditEvent({
domain: event.domain as any,
mutationType: event.mutationType,
target: event.target,
metadata: event.metadata,
} as any);
},
});
}
/**
* Perform an AI-powered merge for a task, serialized through the merge queue.
* This is the manual "merge now" path — it shares the same queue as auto-merge