feat(orchestration): add v4 additive backend core and policy tests

This commit is contained in:
devops committed 2026-10-22 18:15:32 +00:00
1 parent eb17c8e284
commit e5c83e87fe
18 files changed
+586 -14

No files matched your search

@@ -0,0 +1,13 @@
import { Body, Controller, Get, Param, Post, Put, Req, UseGuards } from "@nestjs/common";
import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";
import { JwtAuthGuard } from "../auth/jwt-auth.guard"; import { RolesGuard } from "../common/guards/roles.guard"; import { Roles } from "../common/decorators/roles.decorator";
import { CreateOrchestrationTaskDto, GateDecisionDto, RecordBudgetDto, SetKillSwitchDto, TransitionTaskDto } from "./dto/orchestration.dto"; import { OrchestrationService } from "./orchestration.service";
@ApiTags("Admin - Orchestration v4") @ApiBearerAuth() @UseGuards(JwtAuthGuard,RolesGuard) @Roles("Admin","SUPER_ADMIN") @Controller("admin/orchestration")
export class OrchestrationController { constructor(private readonly service:OrchestrationService){} private actor(req:any){return String(req.user?.id??req.user?.sub??"SYSTEM")}
@Get("tasks") all(){return this.service.findAll()} @Get("tasks/:id") one(@Param("id")id:string){return this.service.findOne(id)}
@Post("tasks") create(@Body()dto:CreateOrchestrationTaskDto,@Req()req:any){return this.service.createTask(dto,this.actor(req))}
@Put("tasks/:id/transition") transition(@Param("id")id:string,@Body()dto:TransitionTaskDto,@Req()req:any){return this.service.transition(id,dto,this.actor(req))}
@Post("tasks/:id/gates/:gate/decide") decide(@Param("id")id:string,@Param("gate")gate:string,@Body()dto:GateDecisionDto,@Req()req:any){if(gate!=="1"&&gate!=="2")throw new Error("gate must be 1 or 2");return this.service.decideGate(id,Number(gate) as 1|2,dto,this.actor(req))}
@Post("tasks/:id/budget") budget(@Param("id")id:string,@Body()dto:RecordBudgetDto,@Req()req:any){return this.service.recordBudget(id,dto,this.actor(req))}
@Put("kill-switch") kill(@Body()dto:SetKillSwitchDto,@Req()req:any){return this.service.setKillSwitch(dto.level,dto.reason,this.actor(req))}
}