Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/app/api/projects/compose/build-publish/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,21 @@ export async function POST(req: NextRequest) {
const resolved = await resolveComposeProjectPath(projectSlug, undefined, vps);
const projectPath = resolved.projectPath;

const project = await prisma.project.findFirst({
where: { OR: [{ slug: projectSlug }, { path: projectPath }] },
});
if (!project) {
throw new HttpError("Build requires a managed GroundControl project.", 409);
}
// Any enrolled deployment with a linked GitHub repository and a compose
// path is buildable. The legacy Project / managementMode gate was removed
// so new deployments are MCP-drivable without a manual "manage" step.
const enrolled = await prisma.enrolledDeployment.findFirst({
where: {
OR: [
{ legacyProjectId: project.id },
{ sourcePath: projectPath },
{ slug: projectSlug },
],
},
select: { id: true, managementMode: true, composePath: true },
select: { id: true, composePath: true },
});
if (!enrolled) {
throw new HttpError("Build is not enrolled in GroundControl.", 409);
}
if (enrolled.managementMode !== "managed") {
throw new HttpError("Build requires managementMode=managed.", 409);
}

const sourceSync = await syncGithubDeploymentSource({
deploymentId: enrolled.id,
Expand Down
12 changes: 4 additions & 8 deletions src/app/api/projects/compose/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,25 +418,21 @@ export async function POST(req: NextRequest) {

let sourceSync: Awaited<ReturnType<typeof syncGithubDeploymentSource>> | null = null;
if (isSourceDeploy) {
if (!project) {
throw new HttpError("Source deployment requires a managed GroundControl project.", 409);
}
// Any enrolled deployment with a linked GitHub repository and a compose
// path is source-deployable. The legacy Project / managementMode gate was
// removed so new deployments are MCP-drivable without a manual "manage" step.
const enrolled = await prisma.enrolledDeployment.findFirst({
where: {
OR: [
{ legacyProjectId: project.id },
{ sourcePath: target.projectPath },
{ slug: projectSlug },
],
},
select: { id: true, managementMode: true },
select: { id: true },
});
if (!enrolled) {
throw new HttpError("Source deployment is not enrolled in GroundControl.", 409);
}
if (enrolled.managementMode !== "managed") {
throw new HttpError("Source deployment requires managementMode=managed.", 409);
}

redeployPhase = "source";
await recordRedeployEvidence(
Expand Down
9 changes: 3 additions & 6 deletions src/lib/mcp-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,9 @@ export async function executeAgentTool(

if (name === "deployment.source.deploy") {
const deployment = await allowedDeployment(context, args.deployment);
if (deployment.managementMode !== "managed") {
throw new Error("Source deployment requires a GroundControl-managed deployment.");
}
if (!deployment.legacyProject) {
throw new Error("This deployment does not have a managed GroundControl project.");
}
// Any enrolled deployment with a linked GitHub repository and a compose
// path is source-deployable. The legacy Project / managementMode gate was
// removed so new deployments are MCP-drivable without a manual "manage" step.
const idempotencyKey = String(args.idempotencyKey || "").trim();
if (idempotencyKey.length < 8 || idempotencyKey.length > 160) {
throw new Error("idempotencyKey must be between 8 and 160 characters");
Expand Down
Loading